Skip to content

Commit

Permalink
Merge pull request #103 from chamilaadhi/master
Browse files Browse the repository at this point in the history
Add basic auth support for backend EP
  • Loading branch information
malinthaprasan authored Jun 29, 2018
2 parents 059ce94 + 7850667 commit 9445884
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ endpoint http:Client {{qualifiedServiceName}}_PROD_EP {
cache: { enabled: false }
{{else}},
cache: { isShared: true }
{{/equals}}{{#api.endpointSecurity}}{{#equals api.endpointSecurity.type "basic"}},
auth: {
scheme: "Basic",
username: gateway:retrieveConfig("{{api.name}}.{{api.version}}.basic.username", "{{api.endpointSecurity.username}}"),
password: gateway:retrieveConfig("{{api.name}}.{{api.version}}.basic.password", "")
}
{{/equals}}
{{/api.endpointSecurity}}
};
{{/endpointConfig.prodEndpoints}}
{{#endpointConfig.sandEndpoints}}
Expand All @@ -22,7 +29,14 @@ endpoint http:Client {{qualifiedServiceName}}_SAND_EP {
cache: { enabled: false }
{{else}},
cache: { isShared: true }
{{/equals}}{{#api.endpointSecurity}}{{#equals api.endpointSecurity.type "basic"}},
auth: {
scheme: "Basic",
username: gateway:retrieveConfig("{{api.name}}.{{api.version}}.basic.username", "{{api.endpointSecurity.username}}"),
password: gateway:retrieveConfig("{{api.name}}.{{api.version}}.basic.password", "")
}
{{/equals}}
{{/api.endpointSecurity}}
};
{{/endpointConfig.sandEndpoints}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ public function retrieveEndPointURL(string key, string default) returns string {
return config:getAsString(key, default = default);
}

@Description {value:"Retrieve external configurations defined against a key"}
public function retrieveConfig(string key, string default) returns string {
return config:getAsString(key, default = default);
}

function initStreamPublisher() {
log:printInfo("Subscribing writing method to event stream");
eventStream.subscribe(writeEventToFile);
Expand Down

0 comments on commit 9445884

Please sign in to comment.