Java Code Examples for org.keycloak.provider.ProviderConfigProperty#setDefaultValue()

The following examples show how to use org.keycloak.provider.ProviderConfigProperty#setDefaultValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamicIdpRedirectAuthenticatorFactory.java    From keycloak-extension-playground with Apache License 2.0 6 votes vote down vote up
@Override
public List<ProviderConfigProperty> getConfigProperties() {

    ProviderConfigProperty emailToIdpMapping = new ProviderConfigProperty();
    emailToIdpMapping.setType(ProviderConfigProperty.STRING_TYPE);
    emailToIdpMapping.setName(DynamicIdpRedirectAuthenticator.EMAIL_TO_IDP_MAPPING_CONFIG_PROPERTY);
    emailToIdpMapping.setLabel("Email IDP Mapping");
    emailToIdpMapping.setHelpText("Email Suffix pattern to IDP Mapping. email-suffix/idp-id, multiple patterns can be delimited via ';', c.f.: example.com/idp1;.*foo.com/idp2;.*bar.(com|de)/idp3");

    ProviderConfigProperty fallbackToAuthFlow = new ProviderConfigProperty();
    fallbackToAuthFlow.setType(ProviderConfigProperty.BOOLEAN_TYPE);
    fallbackToAuthFlow.setName(DynamicIdpRedirectAuthenticator.FALLBACK_TO_AUTHFLOW_CONFIG_PROPERTY);
    fallbackToAuthFlow.setLabel("Fallback to Authflow");
    fallbackToAuthFlow.setHelpText("Fall back to Authflow if no target IdP could be identified.");
    fallbackToAuthFlow.setDefaultValue("true");

    return Arrays.asList(emailToIdpMapping, fallbackToAuthFlow);
}
 
Example 2
Source File: SelectUserAuthenticatorFormFactory.java    From keycloak-extension-playground with Apache License 2.0 5 votes vote down vote up
@Override
public List<ProviderConfigProperty> getConfigProperties() {

    ProviderConfigProperty useAjax = new ProviderConfigProperty();
    useAjax.setType(ProviderConfigProperty.BOOLEAN_TYPE);
    useAjax.setName(SelectUserAuthenticatorForm.USE_AXJAX_CONFIG_PROPERTY);
    useAjax.setLabel("Use AJAX");
    useAjax.setHelpText("Use asynchronous froms submitted via AJAX");
    useAjax.setDefaultValue(true);

    return Arrays.asList(useAjax);
}
 
Example 3
Source File: AddressMapper.java    From keycloak with Apache License 2.0 5 votes vote down vote up
protected static ProviderConfigProperty createConfigProperty(String claimName) {
    ProviderConfigProperty property = new ProviderConfigProperty();
    property.setName(getModelPropertyName(claimName));
    property.setLabel("addressClaim." + claimName + ".label");
    property.setHelpText("addressClaim." + claimName + ".tooltip");
    property.setType(ProviderConfigProperty.STRING_TYPE);
    property.setDefaultValue(claimName);
    return property;
}
 
Example 4
Source File: ScriptBasedAuthenticatorFactory.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public List<ProviderConfigProperty> getConfigProperties() {

    ProviderConfigProperty name = new ProviderConfigProperty();
    name.setType(STRING_TYPE);
    name.setName(SCRIPT_NAME);
    name.setLabel("Script Name");
    name.setHelpText("The name of the script used to authenticate.");

    ProviderConfigProperty description = new ProviderConfigProperty();
    description.setType(STRING_TYPE);
    description.setName(SCRIPT_DESCRIPTION);
    description.setLabel("Script Description");
    description.setHelpText("The description of the script used to authenticate.");

    ProviderConfigProperty script = new ProviderConfigProperty();
    script.setType(SCRIPT_TYPE);
    script.setName(SCRIPT_CODE);
    script.setLabel("Script Source");

    String scriptTemplate = "//enter your script code here";
    try {
        scriptTemplate = StreamUtil.readString(getClass().getResourceAsStream("/scripts/authenticator-template.js"));
    } catch (IOException ioe) {
        LOGGER.warn(ioe);
    }
    script.setDefaultValue(scriptTemplate);
    script.setHelpText("The script used to authenticate. Scripts must at least define a function with the name 'authenticate(context)' that accepts a context (AuthenticationFlowContext) parameter.\n" +
            "This authenticator exposes the following additional variables: 'script', 'realm', 'user', 'session', 'authenticationSession', 'httpRequest', 'LOG'");

    return asList(name, description, script);
}
 
Example 5
Source File: ConditionalOtpFormAuthenticatorFactory.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public List<ProviderConfigProperty> getConfigProperties() {

    ProviderConfigProperty forceOtpUserAttribute = new ProviderConfigProperty();
    forceOtpUserAttribute.setType(STRING_TYPE);
    forceOtpUserAttribute.setName(OTP_CONTROL_USER_ATTRIBUTE);
    forceOtpUserAttribute.setLabel("OTP control User Attribute");
    forceOtpUserAttribute.setHelpText("The name of the user attribute to explicitly control OTP auth. " +
            "If attribute value is 'force' then OTP is always required. " +
            "If value is 'skip' the OTP auth is skipped. Otherwise this check is ignored.");

    ProviderConfigProperty skipOtpRole = new ProviderConfigProperty();
    skipOtpRole.setType(ROLE_TYPE);
    skipOtpRole.setName(SKIP_OTP_ROLE);
    skipOtpRole.setLabel("Skip OTP for Role");
    skipOtpRole.setHelpText("OTP is always skipped if user has the given Role.");

    ProviderConfigProperty forceOtpRole = new ProviderConfigProperty();
    forceOtpRole.setType(ROLE_TYPE);
    forceOtpRole.setName(FORCE_OTP_ROLE);
    forceOtpRole.setLabel("Force OTP for Role");
    forceOtpRole.setHelpText("OTP is always required if user has the given Role.");

    ProviderConfigProperty skipOtpForHttpHeader = new ProviderConfigProperty();
    skipOtpForHttpHeader.setType(STRING_TYPE);
    skipOtpForHttpHeader.setName(SKIP_OTP_FOR_HTTP_HEADER);
    skipOtpForHttpHeader.setLabel("Skip OTP for Header");
    skipOtpForHttpHeader.setHelpText("OTP is skipped if a HTTP request header does matches the given pattern." +
            "Can be used to specify trusted networks via: X-Forwarded-Host: (1.2.3.4|1.2.3.5)." +
            "In this case requests from 1.2.3.4 and 1.2.3.5 come from a trusted source.");
    skipOtpForHttpHeader.setDefaultValue("");

    ProviderConfigProperty forceOtpForHttpHeader = new ProviderConfigProperty();
    forceOtpForHttpHeader.setType(STRING_TYPE);
    forceOtpForHttpHeader.setName(FORCE_OTP_FOR_HTTP_HEADER);
    forceOtpForHttpHeader.setLabel("Force OTP for Header");
    forceOtpForHttpHeader.setHelpText("OTP required if a HTTP request header matches the given pattern.");
    forceOtpForHttpHeader.setDefaultValue("");

    ProviderConfigProperty defaultOutcome = new ProviderConfigProperty();
    defaultOutcome.setType(LIST_TYPE);
    defaultOutcome.setName(DEFAULT_OTP_OUTCOME);
    defaultOutcome.setLabel("Fallback OTP handling");
    defaultOutcome.setOptions(asList(SKIP, FORCE));
    defaultOutcome.setHelpText("What to do in case of every check abstains. Defaults to force OTP authentication.");

    return asList(forceOtpUserAttribute, skipOtpRole, forceOtpRole, skipOtpForHttpHeader, forceOtpForHttpHeader, defaultOutcome);
}