Skip to content

Commit

Permalink
Merge pull request #3603 from mevan-karu/api_key_impl
Browse files Browse the repository at this point in the history
Add temporary API Key authenticator impl
  • Loading branch information
VirajSalaka authored Oct 21, 2024
2 parents c7f4486 + 4d464c5 commit 8504e88
Show file tree
Hide file tree
Showing 15 changed files with 357 additions and 29 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
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class APIConstants {
public static final String API_SECURITY_MUTUAL_SSL = "mutualssl";
public static final String API_SECURITY_BASIC_AUTH = "basic_auth";
public static final String SWAGGER_API_KEY_AUTH_TYPE_NAME = "apiKey";
public static final String API_SECURITY_CHOREO_API_KEY = "api_key";
public static final String SWAGGER_API_KEY_IN_HEADER = "header";
public static final String SWAGGER_API_KEY_IN_QUERY = "query";
public static final String API_SECURITY_MUTUAL_SSL_MANDATORY = "mutualssl_mandatory";
Expand Down
Loading

0 comments on commit 8504e88

Please sign in to comment.