Skip to content

Commit

Permalink
Merge pull request #135 from krakend/dev-2.5-ee
Browse files Browse the repository at this point in the history
2.5 EE
  • Loading branch information
alombarte authored Mar 11, 2024
2 parents c31852b + ca42eb8 commit fec806e
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 17 deletions.
15 changes: 1 addition & 14 deletions src/app/designer.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ angular
}

$rootScope.modules_in_use = [];
service_components = ['documentation/openapi', 'auth/api-keys', 'telemetry/newrelic', 'server/virtualhost', 'server/static-filesystem'];
service_components = ['documentation/openapi', 'auth/api-keys', 'telemetry/newrelic', 'telemetry/moesif', 'server/virtualhost', 'server/static-filesystem'];
endpoint_components = ['documentation/openapi', 'websocket', 'modifier/jmespath', 'security/policies', 'modifier/response-body-generator'];
backend_components = ['auth/gcp','auth/ntlm','backend/http/client','backend/soap', 'modifier/jmespath', 'security/policies', 'modifier/body-generator', 'modifier/response-body-generator', 'backend/static-filesystem'];
http_server_plugins = ['ip-filter', 'jwk-aggregator', 'krakend-afero', 'basic-auth', 'geoip', 'redis-ratelimit', 'url-rewrite', 'wildcard'];
Expand Down Expand Up @@ -814,19 +814,6 @@ angular
}
};

$rootScope.updateNonGETBackends = function (endpoint_index, old_value, message) {

var num_backends = ('undefined' === typeof $rootScope.service.endpoints[endpoint_index].backend ? 0 : $rootScope.service.endpoints[endpoint_index].backend.length);
if (num_backends > 1) {
if (old_value == 'GET' && confirm(message)) {
$rootScope.service.endpoints[endpoint_index].backend.splice(1, 10000);
} else {
// Angular already updated the value, revert:
$rootScope.service.endpoints[endpoint_index].method = 'GET';
}
}
};

/**
* The setNoOpEncoding is called when the backend or the endpoint change their encoding.
* It deletes all backend configuration and adds a backend with no-op.
Expand Down
4 changes: 4 additions & 0 deletions src/app/designer.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
templateUrl: '/src/app/forms/api-keys.html',
controller: 'KrakenDesignerController'
})
.when('/monetization', {
templateUrl: '/src/app/forms/monetization.html',
controller: 'KrakenDesignerController'
})
.otherwise({
redirectTo: '/'
});
Expand Down
5 changes: 2 additions & 3 deletions src/app/forms/endpoints.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ <h3 class="box-title text-xl">
<div class="col-md-2 col-sm-2">
<label>Method</label>
<select id="endpoint.method" ng-model="endpoint.method" name="endpoint.method"
class="form-control"
ng-change="updateNonGETBackends(endpoint_index, '{{ endpoint.method }}', 'Non-GET methods forward the request to a single backend query (the first one). The rest will be deleted from this form. Proceed?')">
class="form-control">
<option value="GET">GET</option>
<option value="POST">POST</option>
<option value="PUT">PUT</option>
Expand Down Expand Up @@ -623,7 +622,7 @@ <h4 class="modal-title">Add hosts</h4>

<div class="col-md-12">
<button class="btn btn-primary" ng-click="addBackendQuery(endpoint_index)"
ng-if="! endpoint.backend || endpoint.backend.length < 1 || ( endpoint.method =='GET' && !(endpoint.output_encoding == 'no-op' && endpoint.backend.length > 0))">
ng-if="! endpoint.backend || endpoint.backend.length < 1 || !(endpoint.output_encoding == 'no-op' && endpoint.backend.length > 0)">
<i class="fa fa-plus"></i>
Add backend query
</button>
Expand Down
25 changes: 25 additions & 0 deletions src/app/forms/monetization.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div class="row">
<div class="col-md-6">
<div>
<middleware data="service" namespace="'telemetry/moesif'" template="monetization.html"></middleware>
</div>
</div>
<div class="col-md-6">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Moesif Dashboard</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-md-12">
<p>View your governance rules, analytics, and monetization settings on <a href="https://www.moesif.com" target="_blank">Moesif's dashboard</a>
</p>
<a href="https://www.moesif.com" target="_blank">
<img style="width: 100%;" src="http://localhost:1313/images/blog/company-announcements/moesif-partnership.svg">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions src/app/forms/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<li><a href="/#!/service"><i class="fa fa-gear"></i>Service settings</a></li>
<li><a href="/#!/security"><i class="fa fa-shield"></i>HTTP Security</a></li>
<li><a href="/#!/monetization"><i class="fa fa-dollar"></i>API Monetization and Governance</a></li>
<li><a href="/#!/logging"><i class="fa fa-area-chart"></i> <span>Telemetry and Analytics</span></a>
<li><a href="/#!/api-keys"><i class="fa fa-key"></i> <span>API Keys</span></a>
<li><a href="/#!/openapi"><i class="fa fa-book"></i> <span>OpenAPI</span></a>
Expand Down
85 changes: 85 additions & 0 deletions src/app/middlewares/monetization.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<div class="box box-info box-solid">
<div class="box-header with-border">
<h3 class="box-title"><input type="checkbox" ng-checked="isMiddlewareEnabled()" ng-click="toggleMiddleware()"> API
Monetization and API Governance (Moesif partnership)</h3>
<div class="pull-right" ng-include src="'/src/app/layout/docs.html'"
ng-repeat="doc in [{'ee': true, 'url':'/governance/moesif/'}]"></div>
</div>
<div class="box-body">
<p ng-if="!isMiddlewareEnabled()">Enable the API Monetization module and start generating revenue from your APIs.
The monetization integration
is possible thanks to our partnership with Moesif.</p>
<div ng-if="isMiddlewareEnabled()">
<div class="form-group">
<div class="row">
<div class="col-md-12">
<p>Check the <a href="https://www.krakend.io/governance/moesif/">documentation</a> for more advanced usages
and company identification</p>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label class="control-label">Application ID</label>
<input type="text" class="form-control" ng-model="data.extra_config[config_namespace].application_id"
placeholder="XXXX">
<span class="help-block">
The Collector Application ID is used to send events, actions, users, and companies to Moesif's Collector
API. Moesif provides it under the 'API Keys' section.
</span>
</div>
<div class="col-md-6">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="data.extra_config[config_namespace].debug">
<strong>Debug</strong>
</label>
<span class="help-block">Set to true when configuring Moesif for the first time while in development, to
see the activity in the logs. Set to false in production.</span>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-8">
<label class="control-label" for="data.extra_config[config_namespace].user_id_headers">Headers to
identify user ID</label>
<div class="input-group">
<input class="form-control" placeholder="my-indexing" type="text" required=""
ng-model="input_user_id_headers">
<div class="input-group-btn">
<button type="button" class="btn btn-success"
ng-click="addTermToList(input_user_id_headers,'user_id_headers')">
<i class="fa fa-plus"></i>
</button>
</div>
</div>
<span class="help-block">Defines the list of possible headers that can identify a user uniquely. When the
header is <code>Authorization</code>, it automatically extracts the username if it contains an
<code>Authorization: Basic</code> value with no additional configuration. If, on the other hand, you use
tokens and pass an <code>Authorization: Bearer</code>, it will extract the user ID from the JWT claim
defined under <code>user_id_jwt_claim</code>. If there are multiple headers in the list, all of them are
tested in the given order, and the first existing header in the list is used to extract the user ID
(successfully or not). </span>
<ul class="list-unstyled list-inline">
<li ng-repeat="(index,header) in data.extra_config[config_namespace].user_id_headers">
<a class="badge code badge-remove" ng-click="deleteIndexFromList(index,'user_id_headers')"><i
class="fa fa-times"></i>
{{ header }}</a>
</li>
</ul>
</div>
<div class="col-md-4">
<label class="control-label">Claim with User ID</label>
<input type="text" class="form-control" ng-model="data.extra_config[config_namespace].user_id_jwt_claim"
placeholder="sub">
<span class="help-block">
When using JWT tokens, it defines which claim contains the user ID.
</span>
</div>
</div>
</div>

</div>
</div>
</div>

0 comments on commit fec806e

Please sign in to comment.