From 2c3b7d70fc243f90bf127b8ec23fd999dcfd02b7 Mon Sep 17 00:00:00 2001 From: nizyev Date: Tue, 2 Jun 2015 16:34:18 +0300 Subject: [PATCH 01/28] created file for schema and added basic fields --- client/views/add_api/add_api.coffee | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 client/views/add_api/add_api.coffee diff --git a/client/views/add_api/add_api.coffee b/client/views/add_api/add_api.coffee new file mode 100644 index 0000000000..cb084859fe --- /dev/null +++ b/client/views/add_api/add_api.coffee @@ -0,0 +1,19 @@ +Schemas.NewApi = new SimpleSchema + name: + type: String + + backend_protocol: + type: String + + backend_host: + type: String + + backend_port: + type: Number + + frontend_host: + type: String + + balance_algorithm: + type: String + From 0123366fd525308ace7345d2162eda0da75f957e Mon Sep 17 00:00:00 2001 From: nizyev Date: Tue, 2 Jun 2015 16:44:45 +0300 Subject: [PATCH 02/28] renamed file and folder --- .../{add_api/add_api.coffee => api_configuration/backend.coffee} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/views/{add_api/add_api.coffee => api_configuration/backend.coffee} (100%) diff --git a/client/views/add_api/add_api.coffee b/client/views/api_configuration/backend.coffee similarity index 100% rename from client/views/add_api/add_api.coffee rename to client/views/api_configuration/backend.coffee From f8f3d15ace718d845bcf3d9fed20869e0e3d6102 Mon Sep 17 00:00:00 2001 From: nizyev Date: Tue, 2 Jun 2015 16:54:34 +0300 Subject: [PATCH 03/28] files for different schemas --- client/views/api_configuration/api.coffee | 0 client/views/api_configuration/rewrite.coffee | 0 client/views/api_configuration/settings.coffee | 0 client/views/api_configuration/sub_settings.coffee | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 client/views/api_configuration/api.coffee create mode 100644 client/views/api_configuration/rewrite.coffee create mode 100644 client/views/api_configuration/settings.coffee create mode 100644 client/views/api_configuration/sub_settings.coffee diff --git a/client/views/api_configuration/api.coffee b/client/views/api_configuration/api.coffee new file mode 100644 index 0000000000..e69de29bb2 diff --git a/client/views/api_configuration/rewrite.coffee b/client/views/api_configuration/rewrite.coffee new file mode 100644 index 0000000000..e69de29bb2 diff --git a/client/views/api_configuration/settings.coffee b/client/views/api_configuration/settings.coffee new file mode 100644 index 0000000000..e69de29bb2 diff --git a/client/views/api_configuration/sub_settings.coffee b/client/views/api_configuration/sub_settings.coffee new file mode 100644 index 0000000000..e69de29bb2 From cc2e85925bdf62039d69333990060e95cb4a5c0d Mon Sep 17 00:00:00 2001 From: nizyev Date: Wed, 3 Jun 2015 11:19:39 +0300 Subject: [PATCH 04/28] deleted files, created one for schema collection --- client/views/api_configuration/api.coffee | 0 client/views/api_configuration/rewrite.coffee | 0 client/views/api_configuration/settings.coffee | 0 client/views/api_configuration/sub_settings.coffee | 0 {client/views/api_configuration => collections}/backend.coffee | 1 - 5 files changed, 1 deletion(-) delete mode 100644 client/views/api_configuration/api.coffee delete mode 100644 client/views/api_configuration/rewrite.coffee delete mode 100644 client/views/api_configuration/settings.coffee delete mode 100644 client/views/api_configuration/sub_settings.coffee rename {client/views/api_configuration => collections}/backend.coffee (99%) diff --git a/client/views/api_configuration/api.coffee b/client/views/api_configuration/api.coffee deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/client/views/api_configuration/rewrite.coffee b/client/views/api_configuration/rewrite.coffee deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/client/views/api_configuration/settings.coffee b/client/views/api_configuration/settings.coffee deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/client/views/api_configuration/sub_settings.coffee b/client/views/api_configuration/sub_settings.coffee deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/client/views/api_configuration/backend.coffee b/collections/backend.coffee similarity index 99% rename from client/views/api_configuration/backend.coffee rename to collections/backend.coffee index cb084859fe..f6610686a1 100644 --- a/client/views/api_configuration/backend.coffee +++ b/collections/backend.coffee @@ -16,4 +16,3 @@ Schemas.NewApi = new SimpleSchema balance_algorithm: type: String - From ebb44125b6a1c7ac698bcf4f2494d3ef34b10425 Mon Sep 17 00:00:00 2001 From: nizyev Date: Wed, 3 Jun 2015 15:19:49 +0300 Subject: [PATCH 05/28] added basic variables for a schema --- collections/backend.coffee | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/collections/backend.coffee b/collections/backend.coffee index f6610686a1..7c878c9e2f 100644 --- a/collections/backend.coffee +++ b/collections/backend.coffee @@ -1,9 +1,13 @@ -Schemas.NewApi = new SimpleSchema +Schemas.Api = new SimpleSchema name: type: String backend_protocol: type: String + allowedValues: + 'http', + 'https' + label: 'Backend protocol' backend_host: type: String @@ -14,5 +18,14 @@ Schemas.NewApi = new SimpleSchema frontend_host: type: String - balance_algorithm: - type: String +server: + type: Array + +"server.$": + type: Object + +"server.$. backend_host": + type: String + +"server.$.backend_port": + type: Number From 387bc13ead8a1c2fdc1462e4596f506da4ae8ed9 Mon Sep 17 00:00:00 2001 From: nizyev Date: Wed, 3 Jun 2015 15:45:07 +0300 Subject: [PATCH 06/28] added a basic route page with autoform generated schema --- client/views/api_backends/api_backends.html | 3 + collections/backend.coffee | 62 +++++++++++---------- lib/router/main.coffee | 6 +- 3 files changed, 41 insertions(+), 30 deletions(-) create mode 100644 client/views/api_backends/api_backends.html diff --git a/client/views/api_backends/api_backends.html b/client/views/api_backends/api_backends.html new file mode 100644 index 0000000000..6e6c25e952 --- /dev/null +++ b/client/views/api_backends/api_backends.html @@ -0,0 +1,3 @@ + diff --git a/collections/backend.coffee b/collections/backend.coffee index 7c878c9e2f..cfe20342e6 100644 --- a/collections/backend.coffee +++ b/collections/backend.coffee @@ -1,31 +1,35 @@ -Schemas.Api = new SimpleSchema +@ApiBackends = new Meteor.Collection('apiBackends'); +Schemas.ApiBackends = new SimpleSchema( name: type: String - - backend_protocol: - type: String - allowedValues: - 'http', - 'https' - label: 'Backend protocol' - - backend_host: - type: String - - backend_port: - type: Number - - frontend_host: - type: String - -server: - type: Array - -"server.$": - type: Object - -"server.$. backend_host": - type: String - -"server.$.backend_port": - type: Number +# +# backend_protocol: +# type: String +# allowedValues: +# 'http' +# 'https' +# label: 'Backend protocol' +# +# backend_host: +# type: String +# +# backend_port: +# type: Number +# +# frontend_host: +# type: String +# +# server: +# type: Array +# +# "server.$": +# type: Object +# +# "server.$. backend_host": +# type: String +# +# "server.$.backend_port": +# type: Number +) + +ApiBackends.attachSchema(Schemas.ApiBackends) diff --git a/lib/router/main.coffee b/lib/router/main.coffee index 2e8b2f364c..9f75d86b3c 100644 --- a/lib/router/main.coffee +++ b/lib/router/main.coffee @@ -3,6 +3,10 @@ Router.map -> path: "/" layoutTemplate: "homeLayout" + @route "apiBackends", + path: "/apibackends" + layoutTemplate: "homeLayout" + @route "dashboard", path: "/dashboard" waitOn: -> @@ -12,4 +16,4 @@ Router.map -> subs.subscribe 'attachments' ] data: -> - posts: Posts.find({},{sort: {createdAt: -1}}).fetch() \ No newline at end of file + posts: Posts.find({},{sort: {createdAt: -1}}).fetch() From 71bbe0a8c4668f46ae6f4bbc6187be422f950c4f Mon Sep 17 00:00:00 2001 From: nizyev Date: Thu, 4 Jun 2015 12:48:38 +0300 Subject: [PATCH 07/28] template with autoform embedded added --- client/views/api_backends/api_backends.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/views/api_backends/api_backends.html b/client/views/api_backends/api_backends.html index 6e6c25e952..7c623c3e5e 100644 --- a/client/views/api_backends/api_backends.html +++ b/client/views/api_backends/api_backends.html @@ -1,3 +1,7 @@ From 8aed8f6a7e420c3fd25ca7edbfed6f8fa3f4be86 Mon Sep 17 00:00:00 2001 From: nizyev Date: Thu, 4 Jun 2015 12:48:50 +0300 Subject: [PATCH 08/28] more variables to the schema --- collections/backend.coffee | 54 ++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/collections/backend.coffee b/collections/backend.coffee index cfe20342e6..7d866eda14 100644 --- a/collections/backend.coffee +++ b/collections/backend.coffee @@ -1,35 +1,33 @@ @ApiBackends = new Meteor.Collection('apiBackends'); Schemas.ApiBackends = new SimpleSchema( + name: type: String -# -# backend_protocol: -# type: String -# allowedValues: -# 'http' -# 'https' -# label: 'Backend protocol' -# -# backend_host: -# type: String -# -# backend_port: -# type: Number -# -# frontend_host: -# type: String -# -# server: -# type: Array -# -# "server.$": -# type: Object -# -# "server.$. backend_host": -# type: String -# -# "server.$.backend_port": -# type: Number + + backend_protocol: + type: String + label: 'Backend protocol' + + backend_host: + type: String + + backend_port: + type: Number + + frontend_host: + type: String + + server: + type: Array + + "server.$": + type: Object + + "server.$. backend_host": + type: String + + "server.$.backend_port": + type: Number ) ApiBackends.attachSchema(Schemas.ApiBackends) From 9e620ed68b94203f74c1f702464df62feb031413 Mon Sep 17 00:00:00 2001 From: nizyev Date: Thu, 4 Jun 2015 14:50:34 +0300 Subject: [PATCH 09/28] added couple new variables to the schema --- collections/backend.coffee | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/collections/backend.coffee b/collections/backend.coffee index 7d866eda14..b1a5b4f4e8 100644 --- a/collections/backend.coffee +++ b/collections/backend.coffee @@ -6,6 +6,7 @@ Schemas.ApiBackends = new SimpleSchema( backend_protocol: type: String + allowedValues: ['http', 'https'] label: 'Backend protocol' backend_host: @@ -18,16 +19,26 @@ Schemas.ApiBackends = new SimpleSchema( type: String server: - type: Array + type: [Object] - "server.$": - type: Object - - "server.$. backend_host": + "server.$.backend_host": type: String "server.$.backend_port": - type: Number + type: String + regEx: /^[0-9]{2,5}$/ + + matching: + type: [Object] + + "matching.$.frontend_prefix": + label: 'Frontend Prefix' + type: String + + "matching.$.backend_prefix": + label: 'Backend Prefix' + type: String + regEx: /^[a-z0-9A-Z_]{3,15}$/ ) ApiBackends.attachSchema(Schemas.ApiBackends) From 3b610da87f8a0e3a0651d1e09798c7a02753e6d5 Mon Sep 17 00:00:00 2001 From: nizyev Date: Thu, 4 Jun 2015 14:51:16 +0300 Subject: [PATCH 10/28] changed quickForm to autoForm, added some styling --- client/views/api_backends/api_backends.html | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/client/views/api_backends/api_backends.html b/client/views/api_backends/api_backends.html index 7c623c3e5e..3c15636c15 100644 --- a/client/views/api_backends/api_backends.html +++ b/client/views/api_backends/api_backends.html @@ -1,7 +1,23 @@ From 630e769ea9c4cd9b1fb3057043ae2fe782b8fcd1 Mon Sep 17 00:00:00 2001 From: nizyev Date: Thu, 4 Jun 2015 17:00:30 +0300 Subject: [PATCH 11/28] show form elements inline first attempt --- client/views/api_backends/api_backends.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/views/api_backends/api_backends.html b/client/views/api_backends/api_backends.html index 3c15636c15..5b1f34e0c1 100644 --- a/client/views/api_backends/api_backends.html +++ b/client/views/api_backends/api_backends.html @@ -16,7 +16,11 @@ {{> afQuickField name='frontend_host'}} {{> afQuickField name='server'}} - {{> afQuickField name='matching'}} +
+
+ {{> afQuickField name='matching'}} +
+
{{/autoForm}} From 5fdeea59273ea88b2b81ff7b57400776ed842627 Mon Sep 17 00:00:00 2001 From: nizyev Date: Fri, 5 Jun 2015 11:27:42 +0300 Subject: [PATCH 12/28] back to two lines view --- client/views/api_backends/api_backends.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/views/api_backends/api_backends.html b/client/views/api_backends/api_backends.html index 5b1f34e0c1..26f925c250 100644 --- a/client/views/api_backends/api_backends.html +++ b/client/views/api_backends/api_backends.html @@ -16,11 +16,14 @@ {{> afQuickField name='frontend_host'}} {{> afQuickField name='server'}} + + {{> afQuickField name='matching'}} {{/autoForm}} From f2f010efe68916ec760831d172efe4be1c44565c Mon Sep 17 00:00:00 2001 From: nizyev Date: Mon, 8 Jun 2015 15:11:06 +0300 Subject: [PATCH 13/28] changed schema from coffee to js --- collections/backend.coffee | 44 -------------------------------------- collections/backend.js | 44 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 44 deletions(-) delete mode 100644 collections/backend.coffee create mode 100644 collections/backend.js diff --git a/collections/backend.coffee b/collections/backend.coffee deleted file mode 100644 index b1a5b4f4e8..0000000000 --- a/collections/backend.coffee +++ /dev/null @@ -1,44 +0,0 @@ -@ApiBackends = new Meteor.Collection('apiBackends'); -Schemas.ApiBackends = new SimpleSchema( - - name: - type: String - - backend_protocol: - type: String - allowedValues: ['http', 'https'] - label: 'Backend protocol' - - backend_host: - type: String - - backend_port: - type: Number - - frontend_host: - type: String - - server: - type: [Object] - - "server.$.backend_host": - type: String - - "server.$.backend_port": - type: String - regEx: /^[0-9]{2,5}$/ - - matching: - type: [Object] - - "matching.$.frontend_prefix": - label: 'Frontend Prefix' - type: String - - "matching.$.backend_prefix": - label: 'Backend Prefix' - type: String - regEx: /^[a-z0-9A-Z_]{3,15}$/ -) - -ApiBackends.attachSchema(Schemas.ApiBackends) diff --git a/collections/backend.js b/collections/backend.js new file mode 100644 index 0000000000..55ce9ef6bc --- /dev/null +++ b/collections/backend.js @@ -0,0 +1,44 @@ +ApiBackends = new Meteor.Collection('apiBackends'); +Schemas.ApiBackends = new SimpleSchema({ + name: { + type: String + }, + backend_protocol: { + type: String, + allowedValues: ['http', 'https'], + label: 'Backend protocol' + }, + backend_host: { + type: String + }, + backend_port: { + type: Number + }, + frontend_host: { + type: String + }, + server: { + type: [Object] + }, + "server.$.backend_host": { + type: String + }, + "server.$.backend_port": { + type: String, + regEx: /^[0-9]{2,5}$/ + }, + matching: { + type: [Object] + }, + "matching.$.frontend_prefix": { + label: 'Frontend Prefix', + type: String + }, + "matching.$.backend_prefix": { + label: 'Backend Prefix', + type: String, + regEx: /^[a-z0-9A-Z_]{3,15}$/ + } +}); + +ApiBackends.attachSchema(Schemas.ApiBackends) From 54968305cb3f5d2e6c95c25e04187744b70a1919 Mon Sep 17 00:00:00 2001 From: nizyev Date: Mon, 8 Jun 2015 16:02:49 +0300 Subject: [PATCH 14/28] added more fields --- collections/backend.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/collections/backend.js b/collections/backend.js index 55ce9ef6bc..85c974ef8b 100644 --- a/collections/backend.js +++ b/collections/backend.js @@ -3,6 +3,9 @@ Schemas.ApiBackends = new SimpleSchema({ name: { type: String }, + sort_order: { + type: Integer + }, backend_protocol: { type: String, allowedValues: ['http', 'https'], @@ -17,6 +20,9 @@ Schemas.ApiBackends = new SimpleSchema({ frontend_host: { type: String }, + balance_algorithm: { + type: String + }, server: { type: [Object] }, From b4495a9525ea57dac542f7e4e59a2d49588ad867 Mon Sep 17 00:00:00 2001 From: nizyev Date: Wed, 10 Jun 2015 11:29:07 +0300 Subject: [PATCH 15/28] more variables added --- collections/backend.js | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/collections/backend.js b/collections/backend.js index 85c974ef8b..ac8d723ec7 100644 --- a/collections/backend.js +++ b/collections/backend.js @@ -44,6 +44,96 @@ Schemas.ApiBackends = new SimpleSchema({ label: 'Backend Prefix', type: String, regEx: /^[a-z0-9A-Z_]{3,15}$/ + }, + duration: { + type: Number + }, + accuracy:{ + type: Number + }, + limit_by: { + type: String + }, + limit: { + type: Number + }, + distributed: { + type: Boolean + }, + response_headers: { + type: Boolean + }, + matcher_type: { + type: String + }, + http_method: { + type: String + }, + frontend_matcher: { + type: String + }, + backend_replacement: { + type: String + }, + matcher: { + type: String + }, + http_method: { + type: String + }, + from: { + type: String + }, + to: { + type: String + }, + set_headers: { + type: [Object] + }, + append_query_string: { + type: String + }, + http_basic_auth: { + type: String + }, + require_https: { + type: String + }, + require_https_transition_start_at: { + type: Date + }, + disable_api_key: { + type: Boolean + }, + api_key_verification_level: { + type: String + }, + api_key_verification_transition_start_at: { + type: Date + }, + required_roles: { + type: Array + }, + rate_limit_mode: { + type: String + }, + anonymous_rate_limit_behavior: { + type: String + }, + authenticated_rate_limit_behavior: { + type: String + }, + pass_api_key_header: { + type: Boolean + }, + pass_api_key_query_param: { + type: Boolean + }, + error_templates: { + type: [Object] + }, + error_data: { + type: [Object] } }); From 1685d5c185aa60d90be7efd4a54c673d103437fb Mon Sep 17 00:00:00 2001 From: nizyev Date: Wed, 10 Jun 2015 14:06:28 +0300 Subject: [PATCH 16/28] more variables --- collections/backend.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/collections/backend.js b/collections/backend.js index ac8d723ec7..a15891dc56 100644 --- a/collections/backend.js +++ b/collections/backend.js @@ -4,7 +4,7 @@ Schemas.ApiBackends = new SimpleSchema({ type: String }, sort_order: { - type: Integer + type: Number }, backend_protocol: { type: String, @@ -46,7 +46,8 @@ Schemas.ApiBackends = new SimpleSchema({ regEx: /^[a-z0-9A-Z_]{3,15}$/ }, duration: { - type: Number + type: Number, + label: 'Duration' }, accuracy:{ type: Number @@ -88,7 +89,8 @@ Schemas.ApiBackends = new SimpleSchema({ type: String }, set_headers: { - type: [Object] +// type: [Object] + type: String }, append_query_string: { type: String @@ -97,7 +99,9 @@ Schemas.ApiBackends = new SimpleSchema({ type: String }, require_https: { - type: String + type: String, + allowedValues: ['Inherit (default - optional)', 'Optional - HTTPS is optional', 'Required - HTTPS is mandatory'], + label: 'HTTPS Requirements' }, require_https_transition_start_at: { type: Date @@ -112,10 +116,13 @@ Schemas.ApiBackends = new SimpleSchema({ type: Date }, required_roles: { - type: Array +// type: Array + type: String }, rate_limit_mode: { - type: String + type: String, + allowedValues: ['Default rate limits', 'Custom rate limits', 'Unlimited requests'], + label: 'Rate limit' }, anonymous_rate_limit_behavior: { type: String @@ -130,11 +137,13 @@ Schemas.ApiBackends = new SimpleSchema({ type: Boolean }, error_templates: { - type: [Object] +// type: [Object] + type: String }, error_data: { - type: [Object] +// type: [Object] + type: String } }); -ApiBackends.attachSchema(Schemas.ApiBackends) +ApiBackends.attachSchema(Schemas.ApiBackends); From cccd18e8b22c543d2712f8f7d1422bfe8f34781d Mon Sep 17 00:00:00 2001 From: nizyev Date: Wed, 10 Jun 2015 14:07:38 +0300 Subject: [PATCH 17/28] api-umbrella package updated --- .meteor/versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.meteor/versions b/.meteor/versions index 6881cc076b..4fbdb08895 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -20,7 +20,7 @@ blaze@2.1.2 blaze-tools@1.0.3 boilerplate-generator@1.0.3 bootstrap@0.3.1 -brylie:api-umbrella@0.2.2 +brylie:api-umbrella@0.2.4 callback-hook@1.0.3 cfs:access-point@0.1.49 cfs:base-package@0.0.30 From 495710756a75756841ad2c66fb74ffa84e03331b Mon Sep 17 00:00:00 2001 From: nizyev Date: Wed, 10 Jun 2015 14:11:16 +0300 Subject: [PATCH 18/28] change schema's name --- collections/backend.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/collections/backend.js b/collections/backend.js index a15891dc56..ff48a55575 100644 --- a/collections/backend.js +++ b/collections/backend.js @@ -1,5 +1,6 @@ -ApiBackends = new Meteor.Collection('apiBackends'); -Schemas.ApiBackends = new SimpleSchema({ +ApiBackends = new Mongo.Collection('apiBackends'); + +ApiBackendsSchema = new SimpleSchema({ name: { type: String }, @@ -146,4 +147,5 @@ Schemas.ApiBackends = new SimpleSchema({ } }); -ApiBackends.attachSchema(Schemas.ApiBackends); +ApiBackends.attachSchema(ApiBackendsSchema); + From 6f63b99e6f942bae3c5375d48c6f038fbbdf737d Mon Sep 17 00:00:00 2001 From: nizyev Date: Wed, 10 Jun 2015 16:47:05 +0300 Subject: [PATCH 19/28] new variables, afquickfields --- client/views/api_backends/api_backends.html | 9 +- collections/backend.js | 147 +++++++++++++++----- 2 files changed, 121 insertions(+), 35 deletions(-) diff --git a/client/views/api_backends/api_backends.html b/client/views/api_backends/api_backends.html index 26f925c250..f544f96ed5 100644 --- a/client/views/api_backends/api_backends.html +++ b/client/views/api_backends/api_backends.html @@ -5,7 +5,7 @@ {{> afQuickField name='name'}}
- {{> afQuickField name='backend_protocol'}} + {{> afQuickField name='backend_protocol' options="allowed"}}
{{> afQuickField name='backend_host'}} @@ -24,6 +24,13 @@ --> {{> afQuickField name='matching'}} +

Global Request Settings

+ {{> afQuickField name='append_query_string'}} + {{> afQuickField name='set_headers'}} + {{> afQuickField name='http_basic_auth'}} + {{> afQuickField name='require_https' options="allowed"}} + {{> afQuickField name='api_key_verification_level' options="allowed"}} + {{> afQuickField name='required_roles' options="allowed"}} {{/autoForm}}
diff --git a/collections/backend.js b/collections/backend.js index ff48a55575..9ee0dd6bc7 100644 --- a/collections/backend.js +++ b/collections/backend.js @@ -2,106 +2,151 @@ ApiBackends = new Mongo.Collection('apiBackends'); ApiBackendsSchema = new SimpleSchema({ name: { - type: String + type: String, + optional: true }, sort_order: { - type: Number + type: Number, + optional: true }, backend_protocol: { type: String, - allowedValues: ['http', 'https'], + optional: true, + allowedValues: [ + 'http', + 'https' + ], label: 'Backend protocol' }, backend_host: { - type: String + type: String, + optional: true }, backend_port: { - type: Number + type: Number, + optional: true }, frontend_host: { - type: String + type: String, + optional: true }, balance_algorithm: { - type: String + type: String, + optional: true }, server: { - type: [Object] + type: [Object], + optional: true }, "server.$.backend_host": { - type: String + type: String, + optional: true }, "server.$.backend_port": { type: String, + optional: true, regEx: /^[0-9]{2,5}$/ }, matching: { - type: [Object] + type: [Object], + optional: true, }, "matching.$.frontend_prefix": { label: 'Frontend Prefix', + optional: true, type: String }, "matching.$.backend_prefix": { label: 'Backend Prefix', + optional: true, type: String, regEx: /^[a-z0-9A-Z_]{3,15}$/ }, duration: { type: Number, + optional: true, label: 'Duration' }, accuracy:{ - type: Number + type: Number, + optional: true }, limit_by: { - type: String + type: String, + optional: true }, limit: { - type: Number + type: Number, + optional: true }, distributed: { - type: Boolean + type: Boolean, + optional: true }, response_headers: { - type: Boolean + type: Boolean, + optional: true }, matcher_type: { - type: String + type: String, + optional: true }, http_method: { - type: String + type: String, + optional: true }, frontend_matcher: { - type: String + type: String, + optional: true }, backend_replacement: { - type: String + type: String, + optional: true }, matcher: { - type: String + type: String, + optional: true }, http_method: { - type: String + type: String, + optional: true }, from: { - type: String + type: String, + optional: true }, to: { - type: String + type: String, + optional: true }, set_headers: { -// type: [Object] - type: String + type: String, + optional: true, + min: 20, + max: 1000, + autoform: { + rows: 2 + }, + label: 'Set Headers' }, append_query_string: { - type: String + type: String, + optional: true, + label: 'Append Query String Parameters' }, http_basic_auth: { - type: String + type: String, + optional: true, + label: 'HTTP Basic Authentication' }, require_https: { type: String, - allowedValues: ['Inherit (default - optional)', 'Optional - HTTPS is optional', 'Required - HTTPS is mandatory'], + optional: true, + allowedValues: [ + 'Inherit (default - optional)', + 'Optional - HTTPS is optional', + 'Required - HTTPS is mandatory' + ], label: 'HTTPS Requirements' }, require_https_transition_start_at: { @@ -111,18 +156,51 @@ ApiBackendsSchema = new SimpleSchema({ type: Boolean }, api_key_verification_level: { - type: String + type: String, + optional: true, + allowedValues: [ + 'Inherit (default - required)', + 'Required - API keys are mandatory', + 'Disabled - API keys are optional' + ], + label: 'API Key Checks' }, api_key_verification_transition_start_at: { type: Date }, required_roles: { -// type: Array - type: String - }, + type: Array, + minCount: 1, + maxCount: 3, + optional: true, + label: 'Required Roles', + autoform: { + options: [ + { + label: 'api-umbrella-contact-form', + value: 'api-umbrella-contact-form' + }, + { + label: 'api-umbrella-key-creator', + value: 'api-umbrella-key-creator' + }, + { + label: 'write_access', + value: 'write_access' + } + ] + } + }, + "required_roles.$": { + type: String + }, rate_limit_mode: { type: String, - allowedValues: ['Default rate limits', 'Custom rate limits', 'Unlimited requests'], + allowedValues: [ + 'Default rate limits', + 'Custom rate limits', + 'Unlimited requests' + ], label: 'Rate limit' }, anonymous_rate_limit_behavior: { @@ -132,7 +210,8 @@ ApiBackendsSchema = new SimpleSchema({ type: String }, pass_api_key_header: { - type: Boolean + type: Boolean, + optional: true }, pass_api_key_query_param: { type: Boolean From 34f49d6dffb2890673f371c44d445b7e05d8a440 Mon Sep 17 00:00:00 2001 From: nizyev Date: Wed, 10 Jun 2015 22:39:17 +0300 Subject: [PATCH 20/28] basic example getting apibackends from apiumbrella --- client/subscriptions.js | 1 + client/views/api_backends/api_backends.html | 16 +++++--- collections/backend.js | 9 ++++- server/publish/apiBackends.js | 12 ++++++ server/startup.js | 45 +++++++++++++++------ 5 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 server/publish/apiBackends.js diff --git a/client/subscriptions.js b/client/subscriptions.js index 1a590361e9..64fbd2fe34 100644 --- a/client/subscriptions.js +++ b/client/subscriptions.js @@ -1 +1,2 @@ Meteor.subscribe('apiUmbrellaUsers'); +Meteor.subscribe('apiBackends'); diff --git a/client/views/api_backends/api_backends.html b/client/views/api_backends/api_backends.html index f544f96ed5..c4a5d1e9b7 100644 --- a/client/views/api_backends/api_backends.html +++ b/client/views/api_backends/api_backends.html @@ -16,12 +16,12 @@ {{> afQuickField name='frontend_host'}} {{> afQuickField name='server'}} - {{> afQuickField name='matching'}}

Global Request Settings

@@ -31,6 +31,10 @@

Global Request Settings

{{> afQuickField name='require_https' options="allowed"}} {{> afQuickField name='api_key_verification_level' options="allowed"}} {{> afQuickField name='required_roles' options="allowed"}} +
Pass API Key to Backend (deprecated)
+ {{> afQuickField name='pass_api_key_header'}} + {{> afQuickField name='pass_api_key_query_param'}} + {{> afQuickField name='rate_limit_mode' options="allowed"}} {{/autoForm}} diff --git a/collections/backend.js b/collections/backend.js index 9ee0dd6bc7..ebfcc8d0cb 100644 --- a/collections/backend.js +++ b/collections/backend.js @@ -211,10 +211,15 @@ ApiBackendsSchema = new SimpleSchema({ }, pass_api_key_header: { type: Boolean, - optional: true + optional: true, + defaultValue: false, + label: 'Via HTTP header' }, pass_api_key_query_param: { - type: Boolean + type: Boolean, + optional: true, + defaultValue: false, + label: 'Via GET query parameter' }, error_templates: { // type: [Object] diff --git a/server/publish/apiBackends.js b/server/publish/apiBackends.js new file mode 100644 index 0000000000..bb231cc208 --- /dev/null +++ b/server/publish/apiBackends.js @@ -0,0 +1,12 @@ +Meteor.publish('apibackends', function () { +// var self = this; +// var response = apiUmbrellaWeb.getUsers(); +// +// _.each(response.data, function (item) { +// self.added('apiUmbrellaUsers', Ramdom.id(), item); +// }); +// +// self.ready(); + + return ApiBackends.find(); +}); diff --git a/server/startup.js b/server/startup.js index 359e92c631..218262360d 100644 --- a/server/startup.js +++ b/server/startup.js @@ -1,15 +1,36 @@ +//Meteor.startup(function () { +// // Check if API Umbrella settings are available +// SyncedCron.add({ +// name: 'Sync API Umbrella Users', +// schedule: function(parser) { +// // parser is a later.parse object +// return parser.text('every 1 day'); +// }, +// job: function() { +// Meteor.call("syncApiUmbrellaUsers"); +// } +// }); +//}); +// +//SyncedCron.start(); + + Meteor.startup(function () { // Check if API Umbrella settings are available - SyncedCron.add({ - name: 'Sync API Umbrella Users', - schedule: function(parser) { - // parser is a later.parse object - return parser.text('every 1 day'); - }, - job: function() { - Meteor.call("syncApiUmbrellaUsers"); - } - }); -}); + if (Meteor.settings.api_umbrella) { + // Get users from API Umbrella instance + var response = apiUmbrellaWeb.adminApi.v1.apiBackends.getApiBackends(); + console.log(response.data); -SyncedCron.start(); + // Add each user to collection if not already there + _.each(response.data, function (item) { + // Get existing user + var existingApi = ApiBackends.findOne({'id': item.id}); + + // If user doesn't exist in collection, insert into collection + if (! existingApi ) { + ApiBackends.insert(item); + }; + }); + }; +}); From 898b570d2b13ded42422be51c68c61d990d6d275 Mon Sep 17 00:00:00 2001 From: nizyev Date: Fri, 12 Jun 2015 07:28:55 +0300 Subject: [PATCH 21/28] added config.json to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 46ce86d504..c535341185 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .meteor/.id settings.json .idea/ +/config.json From 9a04225c709456e8f45d59032105f237d02c4750 Mon Sep 17 00:00:00 2001 From: nizyev Date: Fri, 12 Jun 2015 07:30:00 +0300 Subject: [PATCH 22/28] changed title --- client/views/api_backends/api_backends.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/views/api_backends/api_backends.html b/client/views/api_backends/api_backends.html index c4a5d1e9b7..4012998a4a 100644 --- a/client/views/api_backends/api_backends.html +++ b/client/views/api_backends/api_backends.html @@ -3,6 +3,8 @@
{{#autoForm collection="ApiBackends" doc=this id="apiBackends"}} {{> afQuickField name='name'}} +

Host

+
{{> afQuickField name='backend_protocol' options="allowed"}} @@ -14,7 +16,6 @@ {{> afQuickField name='backend_port'}}
- {{> afQuickField name='frontend_host'}} {{> afQuickField name='server'}}