Skip to content

Commit

Permalink
Add temporary API Key authenticator impl
Browse files Browse the repository at this point in the history
  • Loading branch information
mevan-karu committed Oct 18, 2024
1 parent c7f4486 commit 8c36546
Show file tree
Hide file tree
Showing 14 changed files with 350 additions and 32 deletions.
3 changes: 2 additions & 1 deletion adapter/config/default_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ var defaultConfig = &Config{
DropConsoleTestHeaders: true,
},
APIKeyConfig: apiKeyConfig{
OAuthAgentURL: "https://localhost:9443",
InternalAPIKeyHeader: "Choreo-API-Key",
OAuthAgentURL: "https://localhost:9443",
},
PATConfig: patConfig{
TokenExpiryTimeSkew: 1,
Expand Down
3 changes: 2 additions & 1 deletion adapter/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ type authHeader struct {
}

type apiKeyConfig struct {
OAuthAgentURL string `toml:"oauthAgentURL"`
InternalAPIKeyHeader string `toml:"internalAPIKeyHeader"`
OAuthAgentURL string `toml:"oauthAgentURL"`
}

type patConfig struct {
Expand Down
3 changes: 2 additions & 1 deletion adapter/internal/discovery/xds/marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ func MarshalConfig(config *config.Config) *enforcer.Config {
DropConsoleTestHeaders: config.Enforcer.Security.AuthHeader.DropConsoleTestHeaders,
},
ApiKeyConfig: &enforcer.APIKeyConfig{
OauthAgentURL: config.Enforcer.Security.APIKeyConfig.OAuthAgentURL,
InternalAPIKeyHeader: config.Enforcer.Security.APIKeyConfig.InternalAPIKeyHeader,
OauthAgentURL: config.Enforcer.Security.APIKeyConfig.OAuthAgentURL,
},
PatConfig: &enforcer.PATConfig{
TokenExpiryTimeSkew: config.Enforcer.Security.PATConfig.TokenExpiryTimeSkew,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ option java_multiple_files = true;

message APIKeyConfig {
string oauthAgentURL = 1;
string internalAPIKeyHeader = 2;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ private void populateAuthHeaderConfigurations(AuthHeader authHeader) {

private void populateAPIKeyConfigs(APIKeyConfig apiKeyConfig) {
APIKeyDTO apiKeyDTO = new APIKeyDTO();
apiKeyDTO.setApiKeyInternalHeader(apiKeyConfig.getInternalAPIKeyHeader());
apiKeyDTO.setOauthAgentURL(apiKeyConfig.getOauthAgentURL());
config.setApiKeyConfig(apiKeyDTO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@
*/
public class APIKeyDTO {

private String apiKeyInternalHeader;
private String oauthAgentURL;

public String getApiKeyInternalHeader() {
return apiKeyInternalHeader;
}

public void setApiKeyInternalHeader(String apiKeyInternalHeader) {
this.apiKeyInternalHeader = apiKeyInternalHeader;
}

public String getOauthAgentURL() {
return oauthAgentURL;
}
Expand Down
Loading

0 comments on commit 8c36546

Please sign in to comment.