Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit 048476a

Browse files
author
Chris Wiechmann
committed
Some small tweaks for the external authz.
1 parent 4756fdd commit 048476a

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-authorization/src/actions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ async function addExtHTTPAuthzFilter(params, options) {
117117
var cfg = authZConfig.externalHTTP;
118118
if(!cache.has(cacheKey)) {
119119
if(createRequestUri) {
120-
console.log("------------------------------------- URL: " + cfg.uri);
121120
cfg.replacedUri = await createRequestUri(user, cfg, options);
122121
logger.debug(`Request URI created: ${cfg.replacedUri}`);
123122
} else {

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-authorization/test/testConfig/authorization-config-extAuthZ.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var authorizationConfig = {
55
// For how long should the information cached by the API-Builder process
66
cacheTTL: parseInt(process.env.EXT_AUTHZ_CACHE_TTL) ? process.env.EXT_AUTHZ_CACHE_TTL : 300,
77
externalHTTP : {
8-
// e.g.: https://authz.ac.customer.com/api/v1/users/${loginName}/groups?registry=AD&caching=false&filter=apg-t
8+
// e.g.: https://authz.ac.customer.com/api/v1/users/__loginName__/groups?registry=AD&caching=false&filter=apg-t
99
uri: process.env.EXT_AUTHZ_URI,
1010
// e.g.: customProperty1.apimId
1111
restrictionField: "customProperties.field1",
@@ -30,7 +30,7 @@ var authorizationConfig = {
3030

3131
async function createRequestUri(user, cfg, options) {
3232
// Replace the loginName which is part of the URI
33-
return cfg.uri.replace("${loginName}", user.loginName);
33+
return cfg.uri.replace("__loginName__", user.loginName);
3434
}
3535

3636
async function handleResponse(response, elasticQuery, cfg, options) {

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-authorization/test/testConfig/authorization-config-extAuthZCustom.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var authorizationConfig = {
22
// For how long should the information cached by the API-Builder process
33
cacheTTL: parseInt(process.env.EXT_AUTHZ_CACHE_TTL) ? process.env.EXT_AUTHZ_CACHE_TTL : 300,
44
externalHTTP : {
5-
// e.g.: https://authz.ac.customer.com/api/v1/users/${loginName}/groups?registry=AD&caching=false&filter=apg-t
5+
// e.g.: https://authz.ac.customer.com/api/v1/users/__loginName__/groups?registry=AD&caching=false&filter=apg-t
66
uri: process.env.EXT_AUTHZ_URI,
77
// e.g.: customProperty1.apimId
88
restrictionField: "customProperties.field1",
@@ -18,7 +18,7 @@ var authorizationConfig = {
1818

1919
async function createRequestUri(user, cfg, options) {
2020
// Replace the loginName which is part of the URI
21-
return cfg.uri.replace("${loginName}", user.loginName);
21+
return cfg.uri.replace("__loginName__", user.loginName);
2222
}
2323

2424
async function handleResponse(response, elasticQuery, cfg, options) {

config/authorization-config-sample.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var authorizationConfig = {
3838
cacheTTL: parseInt(process.env.EXT_AUTHZ_CACHE_TTL) ? process.env.EXT_AUTHZ_CACHE_TTL : 300,
3939
externalHTTP : {
4040
// URI you want to use for the lookup, the variable loginName will be replaced, all the rest is static
41-
// e.g.: https://authz.ac.customer.com/api/v1/users/${loginName}/groups?registry=AD&caching=false&filter=apg-t
41+
// e.g.: https://authz.ac.customer.com/api/v1/users/__loginName__/groups?registry=AD&caching=false&filter=apg-t
4242
uri: process.env.EXT_AUTHZ_URI,
4343
// Wich indexed field should be used to customize the query
4444
// This field is used in a terms or match clause
@@ -80,7 +80,11 @@ This function is called before the request is send to the external service. You
8080
*/
8181
async function createRequestUri(user, cfg, options) {
8282
// Replace the loginName which is part of the URI
83-
return cfg.uri.replace("${loginName}", user.loginName);
83+
/* Example to use some kind of regex to be performed on the given username
84+
var match = /CN=([0-9a-zA-Z]*)/.exec(username);
85+
var userId = match[1];
86+
*/
87+
return cfg.uri.replace("__loginName__", user.loginName);
8488
}
8589

8690
/*

0 commit comments

Comments
 (0)