Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate system authenticators names at registering. #6489

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
import org.wso2.carbon.identity.role.v2.mgt.core.RoleManagementService;
import org.wso2.carbon.identity.secret.mgt.core.SecretResolveManager;
import org.wso2.carbon.identity.user.profile.mgt.association.federation.FederatedAssociationManager;
import org.wso2.carbon.idp.mgt.IdentityProviderManagementServerException;
import org.wso2.carbon.idp.mgt.IdpManager;
import org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener;
import org.wso2.carbon.stratos.common.listeners.TenantMgtListener;
Expand All @@ -129,6 +130,7 @@

import javax.servlet.Servlet;

import static org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.CUSTOM_AUTHENTICATOR_PREFIX;
import static org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils.promptOnLongWait;
import static org.wso2.carbon.identity.base.IdentityConstants.TRUE;

Expand Down Expand Up @@ -477,8 +479,16 @@ protected void unsetRealmService(RealmService realmService) {
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetAuthenticator"
)
protected void setAuthenticator(ApplicationAuthenticator authenticator) {

protected void setAuthenticator(ApplicationAuthenticator authenticator)
throws IdentityProviderManagementServerException {

/* All custom authenticator names must start with the `custom-` prefix. If a system-defined authenticator is
attempted to be registered at server startup with a name starting with this prefix, an error will be thrown. */
if (authenticator.getName().startsWith(CUSTOM_AUTHENTICATOR_PREFIX)) {
throw new IdentityProviderManagementServerException(String.format("System-defined authenticator names " +
"are not allowed to have the %s prefix. Therefore, %s cannot be registered.",
CUSTOM_AUTHENTICATOR_PREFIX, authenticator.getName()));
}
ApplicationAuthenticatorManager.getInstance().addSystemDefinedAuthenticator(authenticator);

Property[] configProperties = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public abstract class FrameworkConstants {
public static final String COMMONAUTH_COOKIE = "commonAuthId";
public static final String ALLOW_SESSION_CREATION = "allowSessionCreation";
public static final String CONTEXT_PROP_INVALID_EMAIL_USERNAME = "InvalidEmailUsername";
public static final String CUSTOM_AUTHENTICATOR_PREFIX = "custom-";
// Cookie used for post authenticaion sequence tracking
public static final String PASTR_COOKIE = "pastr";
public static final String CLAIM_URI_WSO2_EXT_IDP = "http://wso2.org/claims/externalIDP";
Expand Down
Loading