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

The following examples show how to use org.keycloak.provider.ProviderConfigProperty#setType() . 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: AuthzPolicyAuthenticatorFactory.java    From keycloak-extension-playground with Apache License 2.0 6 votes vote down vote up
@Override
public List<ProviderConfigProperty> getConfigProperties() {

    ProviderConfigProperty clientListPolicy = new ProviderConfigProperty();
    clientListPolicy.setType(ProviderConfigProperty.TEXT_TYPE);
    clientListPolicy.setName(AuthzPolicyAuthenticator.CLIENTS_POLICY);
    clientListPolicy.setLabel("Clients Policy");
    clientListPolicy.setHelpText("References the clients policy defined in the Authorization/Policies section of the realm-management client.");

    ProviderConfigProperty rolePolicy = new ProviderConfigProperty();
    rolePolicy.setType(ProviderConfigProperty.TEXT_TYPE);
    rolePolicy.setName(AuthzPolicyAuthenticator.ROLES_POLICY);
    rolePolicy.setLabel("Roles Policy");
    rolePolicy.setHelpText("References the roles policy defined in the Authorization/Policies section of the realm-management client.");

    return Arrays.asList(clientListPolicy, rolePolicy);
}
 
Example 3
Source File: AccessPolicyAuthenticatorFactory.java    From keycloak-extension-playground with Apache License 2.0 6 votes vote down vote up
@Override
public List<ProviderConfigProperty> getConfigProperties() {

    ProviderConfigProperty accessPolicy = new ProviderConfigProperty();
    accessPolicy.setType(SCRIPT_TYPE);
    accessPolicy.setName(ACCESS_POLICY);
    accessPolicy.setLabel("Access Policy");
    accessPolicy.setHelpText("An access-policy can be defined as a JSON document which holds a list 'p' of access-policy entries. " +
            "An access-policy-entry consists of a client-id regex pattern 'app' and a list of allowed realm- or client-role names. " +
            "Client roles have the form 'clientId.roleName'. " +
            "If a client is not contained in the access-policy the access is always granted. " +
            "If a client is contained in the access-policy but contains an role list with the sole value 'NONE', then access is always denied. " +
            "{\"p\":[\n" +
            "    { \"app\": \"clientIdRegex\", \"allow\": [\"role1\",\"role2\"] }\n" +
            "]}");

    return Arrays.asList(accessPolicy);
}
 
Example 4
Source File: SetUserAttributeAuthenticatorFactory.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public List<ProviderConfigProperty> getConfigProperties() {
    ProviderConfigProperty attributeName = new ProviderConfigProperty();
    attributeName.setType(ProviderConfigProperty.STRING_TYPE);
    attributeName.setName(CONF_ATTR_NAME);
    attributeName.setLabel("Attribute name");
    attributeName.setHelpText("Name of the user attribute to set");

    ProviderConfigProperty attributeValue = new ProviderConfigProperty();
    attributeValue.setType(ProviderConfigProperty.STRING_TYPE);
    attributeValue.setName(CONF_ATTR_VALUE);
    attributeValue.setLabel("Attribute value");
    attributeValue.setHelpText("Value to set in the user attribute");

    return Arrays.asList(attributeName, attributeValue);
}
 
Example 5
Source File: ConditionalUserAttributeValueFactory.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public List<ProviderConfigProperty> getConfigProperties() {
    ProviderConfigProperty authNoteName = new ProviderConfigProperty();
    authNoteName.setType(ProviderConfigProperty.STRING_TYPE);
    authNoteName.setName(CONF_ATTRIBUTE_NAME);
    authNoteName.setLabel("Attribute name");
    authNoteName.setHelpText("Name of the attribute to check");

    ProviderConfigProperty authNoteExpectedValue = new ProviderConfigProperty();
    authNoteExpectedValue.setType(ProviderConfigProperty.STRING_TYPE);
    authNoteExpectedValue.setName(CONF_ATTRIBUTE_EXPECTED_VALUE);
    authNoteExpectedValue.setLabel("Expected attribute value");
    authNoteExpectedValue.setHelpText("Expected value in the attribute");

    ProviderConfigProperty negateOutput = new ProviderConfigProperty();
    negateOutput.setType(ProviderConfigProperty.BOOLEAN_TYPE);
    negateOutput.setName(CONF_NOT);
    negateOutput.setLabel("Negate output");
    negateOutput.setHelpText("Apply a not to the check result");

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

    // TODO add support for selecting an existing group, similar to role selection

    ProviderConfigProperty group = new ProviderConfigProperty();
    group.setType(ProviderConfigProperty.STRING_TYPE);
    group.setName(GROUP);
    group.setLabel("Group");
    group.setHelpText("Required group");

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

    ProviderConfigProperty role = new ProviderConfigProperty();
    role.setType(ROLE_TYPE);
    role.setName(ROLE);
    role.setLabel("Role");
    role.setHelpText("Require role.");

    return Arrays.asList(role);
}
 
Example 8
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 9
Source File: PairwiseSubMapperHelper.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static ProviderConfigProperty createSectorIdentifierConfig() {
    ProviderConfigProperty property = new ProviderConfigProperty();
    property.setName(SECTOR_IDENTIFIER_URI);
    property.setType(ProviderConfigProperty.STRING_TYPE);
    property.setLabel(SECTOR_IDENTIFIER_URI_LABEL);
    property.setHelpText(SECTOR_IDENTIFIER_URI_HELP_TEXT);
    return property;
}
 
Example 10
Source File: PairwiseSubMapperHelper.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static ProviderConfigProperty createSaltConfig() {
    ProviderConfigProperty property = new ProviderConfigProperty();
    property.setName(PAIRWISE_SUB_ALGORITHM_SALT);
    property.setType(ProviderConfigProperty.STRING_TYPE);
    property.setLabel(PAIRWISE_SUB_ALGORITHM_SALT_LABEL);
    property.setHelpText(PAIRWISE_SUB_ALGORITHM_SALT_HELP_TEXT);
    return property;
}
 
Example 11
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 12
Source File: OIDCAttributeMapperHelper.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static void addTokenClaimNameConfig(List<ProviderConfigProperty> configProperties) {
    ProviderConfigProperty property = new ProviderConfigProperty();
    property.setName(TOKEN_CLAIM_NAME);
    property.setLabel(TOKEN_CLAIM_NAME_LABEL);
    property.setType(ProviderConfigProperty.STRING_TYPE);
    property.setHelpText(TOKEN_CLAIM_NAME_TOOLTIP);
    configProperties.add(property);
}
 
Example 13
Source File: OIDCAttributeMapperHelper.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static void addJsonTypeConfig(List<ProviderConfigProperty> configProperties) {
    ProviderConfigProperty property = new ProviderConfigProperty();
    property.setName(JSON_TYPE);
    property.setLabel(JSON_TYPE);
    List<String> types = new ArrayList(5);
    types.add("String");
    types.add("long");
    types.add("int");
    types.add("boolean");
    types.add("JSON");
    property.setType(ProviderConfigProperty.LIST_TYPE);
    property.setOptions(types);
    property.setHelpText(JSON_TYPE_TOOLTIP);
    configProperties.add(property);
}
 
Example 14
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 15
Source File: AbstractLDAPStorageMapperFactory.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static ProviderConfigProperty createConfigProperty(String name, String label, String helpText, String type, List<String> options) {
    ProviderConfigProperty configProperty = new ProviderConfigProperty();
    configProperty.setName(name);
    configProperty.setLabel(label);
    configProperty.setHelpText(helpText);
    configProperty.setType(type);
    configProperty.setOptions(options);
    return configProperty;
}
 
Example 16
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);
}