Skip to content

Commit

Permalink
Add config to enable jwt for portals
Browse files Browse the repository at this point in the history
  • Loading branch information
chamilaadhi committed Mar 3, 2024
1 parent 448687f commit bc3869d
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,7 @@ private OAuthConstants() {
public static final String API_STORE_GROUP_EXTRACTOR_IMPLEMENTATION = API_STORE + "GroupingExtractor";
public static final String API_STORE_REST_API_GROUP_EXTRACTOR_IMPLEMENTATION =
API_STORE + "RESTApiGroupingExtractor";
public static final String IS_ENABLE_JWT_FOR_PORTALS = OAUTH_CONFIGS + "EnableJWTForPortals";
public static final String API_CUSTOM_SEQUENCES_FOLDER_LOCATION =
"repository" + File.separator + "resources" + File.separator + "customsequences";
public static final String WORKFLOW_EXTENSION_LOCATION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7052,6 +7052,24 @@ public static boolean isMultiGroupAppSharingEnabled() {
return Boolean.valueOf(multiGrpAppSharing);
}

/**
* Enable jwt for portal logins
*
* @return boolean value of the config
*/
public static boolean isJWTEnabledForPortals() {

APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService()
.getAPIManagerConfiguration();

String isEnabledJwtForPortals = config.getFirstProperty(APIConstants.IS_ENABLE_JWT_FOR_PORTALS);
if (isEnabledJwtForPortals != null) {
return Boolean.valueOf(isEnabledJwtForPortals);
}

return false;

}
/**
* Used to check whether Provisioning Out-of-Band OAuth Clients feature is enabled
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class SettingsDTO {

private List<String> scopes = new ArrayList<String>();
private List<String> gatewayTypes = new ArrayList<String>();
private Boolean isJWTEnabledForLoginTokens = false;
private List<SettingsKeyManagerConfigurationDTO> keyManagerConfiguration = new ArrayList<SettingsKeyManagerConfigurationDTO>();
private Boolean analyticsEnabled = null;

Expand Down Expand Up @@ -62,6 +63,23 @@ public void setGatewayTypes(List<String> gatewayTypes) {
this.gatewayTypes = gatewayTypes;
}

/**
**/
public SettingsDTO isJWTEnabledForLoginTokens(Boolean isJWTEnabledForLoginTokens) {
this.isJWTEnabledForLoginTokens = isJWTEnabledForLoginTokens;
return this;
}


@ApiModelProperty(value = "")
@JsonProperty("IsJWTEnabledForLoginTokens")
public Boolean isIsJWTEnabledForLoginTokens() {
return isJWTEnabledForLoginTokens;
}
public void setIsJWTEnabledForLoginTokens(Boolean isJWTEnabledForLoginTokens) {
this.isJWTEnabledForLoginTokens = isJWTEnabledForLoginTokens;
}

/**
**/
public SettingsDTO keyManagerConfiguration(List<SettingsKeyManagerConfigurationDTO> keyManagerConfiguration) {
Expand Down Expand Up @@ -110,13 +128,14 @@ public boolean equals(java.lang.Object o) {
SettingsDTO settings = (SettingsDTO) o;
return Objects.equals(scopes, settings.scopes) &&
Objects.equals(gatewayTypes, settings.gatewayTypes) &&
Objects.equals(isJWTEnabledForLoginTokens, settings.isJWTEnabledForLoginTokens) &&
Objects.equals(keyManagerConfiguration, settings.keyManagerConfiguration) &&
Objects.equals(analyticsEnabled, settings.analyticsEnabled);
}

@Override
public int hashCode() {
return Objects.hash(scopes, gatewayTypes, keyManagerConfiguration, analyticsEnabled);
return Objects.hash(scopes, gatewayTypes, isJWTEnabledForLoginTokens, keyManagerConfiguration, analyticsEnabled);
}

@Override
Expand All @@ -126,6 +145,7 @@ public String toString() {

sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n");
sb.append(" gatewayTypes: ").append(toIndentedString(gatewayTypes)).append("\n");
sb.append(" isJWTEnabledForLoginTokens: ").append(toIndentedString(isJWTEnabledForLoginTokens)).append("\n");
sb.append(" keyManagerConfiguration: ").append(toIndentedString(keyManagerConfiguration)).append("\n");
sb.append(" analyticsEnabled: ").append(toIndentedString(analyticsEnabled)).append("\n");
sb.append("}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public SettingsDTO fromSettingsToDTO(Boolean isUserAvailable) throws APIManageme
}
settingsDTO.setScopes(getScopeList());
settingsDTO.setGatewayTypes(APIUtil.getGatewayTypes());
settingsDTO.setIsJWTEnabledForLoginTokens(APIUtil.isJWTEnabledForPortals());
return settingsDTO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4594,6 +4594,9 @@ components:
type: array
items:
type: string
IsJWTEnabledForLoginTokens:
type: boolean
default: false
keyManagerConfiguration:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4594,6 +4594,9 @@ components:
type: array
items:
type: string
IsJWTEnabledForLoginTokens:
type: boolean
default: false
keyManagerConfiguration:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5290,6 +5290,9 @@ components:
IsPasswordChangeEnabled:
type: boolean
default: true
IsJWTEnabledForLoginTokens:
type: boolean
default: false
userStorePasswordPattern:
type: string
description: The 'PasswordJavaRegEx' cofigured in the UserStoreManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11915,6 +11915,9 @@ components:
type: string
description: Authorization Header
example: authorization
IsJWTEnabledForLoginTokens:
type: boolean
default: false
customProperties:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class SettingsDTO {
private String defaultAdvancePolicy = null;
private String defaultSubscriptionPolicy = null;
private String authorizationHeader = null;
private Boolean isJWTEnabledForLoginTokens = false;
private List<SettingsCustomPropertiesDTO> customProperties = new ArrayList<SettingsCustomPropertiesDTO>();

/**
Expand Down Expand Up @@ -273,6 +274,23 @@ public void setAuthorizationHeader(String authorizationHeader) {
this.authorizationHeader = authorizationHeader;
}

/**
**/
public SettingsDTO isJWTEnabledForLoginTokens(Boolean isJWTEnabledForLoginTokens) {
this.isJWTEnabledForLoginTokens = isJWTEnabledForLoginTokens;
return this;
}


@ApiModelProperty(value = "")
@JsonProperty("IsJWTEnabledForLoginTokens")
public Boolean isIsJWTEnabledForLoginTokens() {
return isJWTEnabledForLoginTokens;
}
public void setIsJWTEnabledForLoginTokens(Boolean isJWTEnabledForLoginTokens) {
this.isJWTEnabledForLoginTokens = isJWTEnabledForLoginTokens;
}

/**
**/
public SettingsDTO customProperties(List<SettingsCustomPropertiesDTO> customProperties) {
Expand Down Expand Up @@ -314,12 +332,13 @@ public boolean equals(java.lang.Object o) {
Objects.equals(defaultAdvancePolicy, settings.defaultAdvancePolicy) &&
Objects.equals(defaultSubscriptionPolicy, settings.defaultSubscriptionPolicy) &&
Objects.equals(authorizationHeader, settings.authorizationHeader) &&
Objects.equals(isJWTEnabledForLoginTokens, settings.isJWTEnabledForLoginTokens) &&
Objects.equals(customProperties, settings.customProperties);
}

@Override
public int hashCode() {
return Objects.hash(devportalUrl, environment, gatewayTypes, scopes, monetizationAttributes, subscriberContactAttributes, securityAuditProperties, externalStoresEnabled, docVisibilityEnabled, crossTenantSubscriptionEnabled, defaultAdvancePolicy, defaultSubscriptionPolicy, authorizationHeader, customProperties);
return Objects.hash(devportalUrl, environment, gatewayTypes, scopes, monetizationAttributes, subscriberContactAttributes, securityAuditProperties, externalStoresEnabled, docVisibilityEnabled, crossTenantSubscriptionEnabled, defaultAdvancePolicy, defaultSubscriptionPolicy, authorizationHeader, isJWTEnabledForLoginTokens, customProperties);
}

@Override
Expand All @@ -340,6 +359,7 @@ public String toString() {
sb.append(" defaultAdvancePolicy: ").append(toIndentedString(defaultAdvancePolicy)).append("\n");
sb.append(" defaultSubscriptionPolicy: ").append(toIndentedString(defaultSubscriptionPolicy)).append("\n");
sb.append(" authorizationHeader: ").append(toIndentedString(authorizationHeader)).append("\n");
sb.append(" isJWTEnabledForLoginTokens: ").append(toIndentedString(isJWTEnabledForLoginTokens)).append("\n");
sb.append(" customProperties: ").append(toIndentedString(customProperties)).append("\n");
sb.append("}");
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public SettingsDTO fromSettingstoDTO(Boolean isUserAvailable, String organizatio
APIUtil.isExternalStoresEnabled(RestApiCommonUtil.getLoggedInUserTenantDomain()));
settingsDTO.setDocVisibilityEnabled(APIUtil.isDocVisibilityLevelsEnabled());
settingsDTO.setCrossTenantSubscriptionEnabled(APIUtil.isCrossTenantSubscriptionsEnabled());
settingsDTO.setIsJWTEnabledForLoginTokens(APIUtil.isJWTEnabledForPortals());
Map<String, Environment> gatewayEnvironments = APIUtil.getReadOnlyGatewayEnvironments();
String authorizationHeader = APIUtil.getOAuthConfiguration(loggedInUserTenantDomain,
APIConstants.AUTHORIZATION_HEADER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11915,6 +11915,9 @@ components:
type: string
description: Authorization Header
example: authorization
IsJWTEnabledForLoginTokens:
type: boolean
default: false
customProperties:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class SettingsDTO {
private SettingsIdentityProviderDTO identityProvider = null;
private Boolean isAnonymousModeEnabled = true;
private Boolean isPasswordChangeEnabled = true;
private Boolean isJWTEnabledForLoginTokens = false;
private String userStorePasswordPattern = null;
private String passwordPolicyPattern = null;
private Integer passwordPolicyMinLength = null;
Expand Down Expand Up @@ -227,6 +228,23 @@ public void setIsPasswordChangeEnabled(Boolean isPasswordChangeEnabled) {
this.isPasswordChangeEnabled = isPasswordChangeEnabled;
}

/**
**/
public SettingsDTO isJWTEnabledForLoginTokens(Boolean isJWTEnabledForLoginTokens) {
this.isJWTEnabledForLoginTokens = isJWTEnabledForLoginTokens;
return this;
}


@ApiModelProperty(value = "")
@JsonProperty("IsJWTEnabledForLoginTokens")
public Boolean isIsJWTEnabledForLoginTokens() {
return isJWTEnabledForLoginTokens;
}
public void setIsJWTEnabledForLoginTokens(Boolean isJWTEnabledForLoginTokens) {
this.isJWTEnabledForLoginTokens = isJWTEnabledForLoginTokens;
}

/**
* The &#39;PasswordJavaRegEx&#39; cofigured in the UserStoreManager
**/
Expand Down Expand Up @@ -320,6 +338,7 @@ public boolean equals(java.lang.Object o) {
Objects.equals(identityProvider, settings.identityProvider) &&
Objects.equals(isAnonymousModeEnabled, settings.isAnonymousModeEnabled) &&
Objects.equals(isPasswordChangeEnabled, settings.isPasswordChangeEnabled) &&
Objects.equals(isJWTEnabledForLoginTokens, settings.isJWTEnabledForLoginTokens) &&
Objects.equals(userStorePasswordPattern, settings.userStorePasswordPattern) &&
Objects.equals(passwordPolicyPattern, settings.passwordPolicyPattern) &&
Objects.equals(passwordPolicyMinLength, settings.passwordPolicyMinLength) &&
Expand All @@ -328,7 +347,7 @@ public boolean equals(java.lang.Object o) {

@Override
public int hashCode() {
return Objects.hash(grantTypes, scopes, applicationSharingEnabled, mapExistingAuthApps, apiGatewayEndpoint, monetizationEnabled, recommendationEnabled, isUnlimitedTierPaid, identityProvider, isAnonymousModeEnabled, isPasswordChangeEnabled, userStorePasswordPattern, passwordPolicyPattern, passwordPolicyMinLength, passwordPolicyMaxLength);
return Objects.hash(grantTypes, scopes, applicationSharingEnabled, mapExistingAuthApps, apiGatewayEndpoint, monetizationEnabled, recommendationEnabled, isUnlimitedTierPaid, identityProvider, isAnonymousModeEnabled, isPasswordChangeEnabled, isJWTEnabledForLoginTokens, userStorePasswordPattern, passwordPolicyPattern, passwordPolicyMinLength, passwordPolicyMaxLength);
}

@Override
Expand All @@ -347,6 +366,7 @@ public String toString() {
sb.append(" identityProvider: ").append(toIndentedString(identityProvider)).append("\n");
sb.append(" isAnonymousModeEnabled: ").append(toIndentedString(isAnonymousModeEnabled)).append("\n");
sb.append(" isPasswordChangeEnabled: ").append(toIndentedString(isPasswordChangeEnabled)).append("\n");
sb.append(" isJWTEnabledForLoginTokens: ").append(toIndentedString(isJWTEnabledForLoginTokens)).append("\n");
sb.append(" userStorePasswordPattern: ").append(toIndentedString(userStorePasswordPattern)).append("\n");
sb.append(" passwordPolicyPattern: ").append(toIndentedString(passwordPolicyPattern)).append("\n");
sb.append(" passwordPolicyMinLength: ").append(toIndentedString(passwordPolicyMinLength)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public SettingsDTO fromSettingstoDTO(Boolean isUserAvailable, Boolean moneatizat
SettingsDTO settingsDTO = new SettingsDTO();
settingsDTO.setScopes(GetScopeList());
settingsDTO.setApplicationSharingEnabled(APIUtil.isMultiGroupAppSharingEnabled());
settingsDTO.setIsJWTEnabledForLoginTokens(APIUtil.isJWTEnabledForPortals());
settingsDTO.setRecommendationEnabled(recommendationEnabled);
settingsDTO.setMapExistingAuthApps(APIUtil.isMapExistingAuthAppsEnabled());
settingsDTO.setMonetizationEnabled(moneatizationEnabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5290,6 +5290,9 @@ components:
IsPasswordChangeEnabled:
type: boolean
default: true
IsJWTEnabledForLoginTokens:
type: boolean
default: false
userStorePasswordPattern:
type: string
description: The 'PasswordJavaRegEx' cofigured in the UserStoreManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@
<!-- Whether to validate certificate bound access tokens-->
<EnableCertificateBoundAccessToken>{{apim.oauth_config.enable_certificate_bound_access_token}}</EnableCertificateBoundAccessToken>

{% if apim.oauth_config.enable_jwt_for_portals is defined %}
<EnableJWTForPortals>{{apim.oauth_config.enable_jwt_for_portals}}</EnableJWTForPortals>
{% endif %}
</OAuthConfigurations>

<AccessTokenBinding>
Expand Down

0 comments on commit bc3869d

Please sign in to comment.