├── .github └── workflows │ └── maven-publish.yml ├── .gitignore ├── .mvn └── maven.config ├── Dockerfile ├── LICENSE ├── README.md ├── doc ├── account-console.png ├── authentication-flow.png ├── authentication-flow.puml ├── browser-flow.png ├── condition-credential-configured.png ├── condition-device-trusted.png ├── login-trust-device.png └── register-trusted-device.png ├── docker-compose.yml ├── pom.xml ├── realm-test.json ├── run-dev.sh └── spi ├── pom.xml └── src └── main ├── java └── nl │ └── wouterh │ └── keycloak │ └── trusteddevice │ ├── authenticator │ ├── CredentialConfiguredCondition.java │ ├── CredentialConfiguredConditionFactory.java │ ├── RegisterTrustedDeviceAuthenticator.java │ ├── RegisterTrustedDeviceAuthenticatorFactory.java │ ├── TrustedDeviceCondition.java │ └── TrustedDeviceConditionFactory.java │ ├── credential │ ├── TrustedDeviceCredentialData.java │ ├── TrustedDeviceCredentialModel.java │ ├── TrustedDeviceCredentialProvider.java │ ├── TrustedDeviceCredentialProviderFactory.java │ └── TrustedDeviceSecretData.java │ └── util │ ├── TrustedDeviceToken.java │ └── UserAgentParser.java └── resources └── theme-resources ├── messages ├── messages_ca.properties ├── messages_de.properties ├── messages_en.properties ├── messages_es.properties ├── messages_fr.properties └── messages_it.properties └── templates └── trusted-device-register.ftl /.github/workflows/maven-publish.yml: -------------------------------------------------------------------------------- 1 | name: Main 2 | 3 | on: push 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | permissions: 10 | contents: write 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | - name: Set up JDK 17 15 | uses: actions/setup-java@v3 16 | with: 17 | java-version: '17' 18 | distribution: 'temurin' 19 | settings-path: ${{ github.workspace }} 20 | cache: 'maven' 21 | 22 | - name: set values 23 | id: set-values 24 | run: | 25 | if [[ "$REF" == refs/tags/v* ]]; then 26 | echo "version=${REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT 27 | else 28 | echo "version=1.0-SNAPSHOT" >> $GITHUB_OUTPUT 29 | fi 30 | env: 31 | REF: ${{ github.ref }} 32 | 33 | - name: Build with Maven 34 | run: mvn -B -Drevision=$VERSION package --file pom.xml 35 | env: 36 | VERSION: ${{ steps.set-values.outputs.version }} 37 | 38 | - name: Release 39 | uses: softprops/action-gh-release@v1 40 | if: startsWith(github.ref, 'refs/tags/v') 41 | with: 42 | files: 'spi/target/keycloak-spi-trusted-device-*.jar' 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | dependency-reduced-pom.xml 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/ 9 | *.iws 10 | *.iml 11 | *.ipr 12 | 13 | ### Eclipse ### 14 | .apt_generated 15 | .classpath 16 | .factorypath 17 | .project 18 | .settings 19 | .springBeans 20 | .sts4-cache 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | 35 | ### Mac OS ### 36 | .DS_Store 37 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -Drevision=1.0-SNAPSHOT 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/keycloak/keycloak:24.0.5 2 | 3 | #COPY target/lib/*.jar ./providers/ 4 | COPY spi/target/keycloak-spi-trusted-device-*-SNAPSHOT.jar /opt/keycloak/providers/keycloak-spi-trusted-device.jar 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This repository contains the keycloak-spi-trusted-device Keycloak plugin. 4 | 5 | The goal of this plugin is to enable users who log in using multi-factor authentication to trust 6 | their device, so they do not have to provide a second factor when using that device. 7 | 8 | The feature is mentioned as a native capability in Keycloak [here](https://github.com/keycloak/keycloak/issues/8742), 9 | but it has not been implemented yet, and it's uncertain if it ever will be. 10 | Therefore, we are currently implementing it as an extension. 11 | 12 | The functionality is illustrated in the following diagram. Details about the individual components are provided below. 13 | 14 | ![Authentication flow](doc/authentication-flow.png) 15 | 16 | ## Usage 17 | 18 | This plugin provides several components: 19 | 20 | * **Trusted device credential**: Each trusted device is registered as a Keycloak credential, which 21 | can be managed by users or administrators on the account page. 22 | * **Register Trusted Device**: Prompts a user if they want to trust the device they are logging in 23 | on 24 | * **Condition - Device Trusted**: Matches if the user is logging in on a trusted device 25 | * **Condition - Credential Configured**: Matches if the user has any of the specified credentials 26 | configured. This can be used instead of the default **Condition - user configured** which would 27 | also match the **Register Trusted Device** authenticator 28 | 29 | To allow a user to login with either an OTP, webauthn or a trusted device this could be configured 30 | as such: 31 | 32 | ![](doc/browser-flow.png) 33 | ![](doc/condition-device-trusted.png) 34 | ![](doc/condition-credential-configured.png) 35 | ![](doc/register-trusted-device.png) 36 | 37 | Following the above example the user would be prompted for a second factor every 90 days on each 38 | device. 39 | 40 | During login the user will be prompted if they want to trust the device: 41 | 42 | ![](doc/login-trust-device.png) 43 | 44 | They can then manage their trusted devices on the account console: 45 | 46 | ![](doc/account-console.png) 47 | 48 | ## Development 49 | 50 | To set up a local environment, first build the extension using Maven. Then, build a Docker image and start the Docker Compose stack. 51 | 52 | ```bash 53 | mvn package -DskipTests 54 | docker-compose up --build -d 55 | ``` 56 | 57 | A helper script including this command can be found [here](run-dev.sh) 58 | 59 | ## Testing 60 | 61 | Testing is not implemented yet. 62 | 63 | ## Contributions Welcome 64 | 65 | We welcome contributions from the community! If you would like to contribute, please submit a merge request. 66 | If you have any questions or encounter any issues, feel free to open an issue. 67 | We appreciate your help in improving this project. 68 | -------------------------------------------------------------------------------- /doc/account-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wouterh-dev/keycloak-spi-trusted-device/05cb4d8578bac45aee3cb81973567145460816ea/doc/account-console.png -------------------------------------------------------------------------------- /doc/authentication-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wouterh-dev/keycloak-spi-trusted-device/05cb4d8578bac45aee3cb81973567145460816ea/doc/authentication-flow.png -------------------------------------------------------------------------------- /doc/authentication-flow.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | start 3 | 4 | if (User has 2FA configured?) then (yes) 5 | if (User is using trusted device?) then (no) 6 | :Prompt 2FA; 7 | if ({{ 8 | salt 9 | {+ 10 | Trust this device? 11 | [Yes] | [No] 12 | } 13 | }}) then (yes) 14 | :Generate unique device secret; 15 | :Set KEYCLOAK_TRUSTED_DEVICE cookie; 16 | else (no) 17 | stop 18 | endif 19 | else (yes) 20 | stop 21 | endif 22 | else (no) 23 | stop 24 | endif 25 | 26 | stop 27 | @enduml 28 | -------------------------------------------------------------------------------- /doc/browser-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wouterh-dev/keycloak-spi-trusted-device/05cb4d8578bac45aee3cb81973567145460816ea/doc/browser-flow.png -------------------------------------------------------------------------------- /doc/condition-credential-configured.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wouterh-dev/keycloak-spi-trusted-device/05cb4d8578bac45aee3cb81973567145460816ea/doc/condition-credential-configured.png -------------------------------------------------------------------------------- /doc/condition-device-trusted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wouterh-dev/keycloak-spi-trusted-device/05cb4d8578bac45aee3cb81973567145460816ea/doc/condition-device-trusted.png -------------------------------------------------------------------------------- /doc/login-trust-device.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wouterh-dev/keycloak-spi-trusted-device/05cb4d8578bac45aee3cb81973567145460816ea/doc/login-trust-device.png -------------------------------------------------------------------------------- /doc/register-trusted-device.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wouterh-dev/keycloak-spi-trusted-device/05cb4d8578bac45aee3cb81973567145460816ea/doc/register-trusted-device.png -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | 3 | services: 4 | postgres: 5 | image: postgres:14 6 | restart: on-failure 7 | environment: 8 | - POSTGRES_DB=keycloak 9 | - POSTGRES_USER=postgres 10 | - POSTGRES_PASSWORD=postgres 11 | volumes: 12 | - "postgres:/var/lib/postgresql/data" 13 | keycloak: 14 | build: . 15 | restart: on-failure 16 | command: [ 17 | "start-dev", 18 | "--http-port", "8680" 19 | ] 20 | environment: 21 | - KC_DB=postgres 22 | - KC_DB_USERNAME=postgres 23 | - KC_DB_PASSWORD=postgres 24 | - KC_HOSTNAME=localhost 25 | - KC_DB_URL=jdbc:postgresql://postgres/keycloak 26 | - KEYCLOAK_ADMIN=admin 27 | - KEYCLOAK_ADMIN_PASSWORD=admin 28 | - JAVA_OPTS_APPEND=-agentlib:jdwp=transport=dt_socket,server=y,address=0.0.0.0:8681,suspend=n 29 | ports: 30 | - "8680:8680" 31 | - "8681:8681" 32 | volumes: 33 | postgres: 34 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.github.wouterh-dev 7 | keycloak-spi-trusted-device-parent 8 | ${revision} 9 | pom 10 | 11 | 12 | spi 13 | 14 | 15 | keycloak-spi-trusted-device 16 | https://github.com/wouterh-dev/keycloak-spi-trusted-device 17 | 18 | 19 | UTF-8 20 | 17 21 | 17 22 | 24.0.5 23 | 1.18.30 24 | 0.16 25 | 3.11.0 26 | 1.0.1 27 | 28 | 29 | 30 | 31 | org.projectlombok 32 | lombok 33 | ${lombok.version} 34 | provided 35 | 36 | 37 | com.google.auto.service 38 | auto-service-annotations 39 | ${auto-service.version} 40 | provided 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.projectlombok 48 | lombok 49 | ${lombok.version} 50 | 51 | 52 | com.google.auto.service 53 | auto-service-annotations 54 | ${auto-service.version} 55 | 56 | 57 | org.keycloak 58 | keycloak-core 59 | ${keycloak.version} 60 | 61 | 62 | org.keycloak 63 | keycloak-services 64 | ${keycloak.version} 65 | 66 | 67 | org.keycloak 68 | keycloak-model-jpa 69 | ${keycloak.version} 70 | 71 | 72 | org.keycloak 73 | keycloak-server-spi 74 | ${keycloak.version} 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | io.github.zlika 83 | reproducible-build-maven-plugin 84 | ${reproducible-build-maven-plugin.version} 85 | 86 | 87 | package 88 | 89 | strip-jar 90 | 91 | 92 | 93 | 94 | 95 | maven-compiler-plugin 96 | ${maven-compiler-plugin.version} 97 | 98 | 99 | 100 | org.projectlombok 101 | lombok 102 | ${lombok.version} 103 | 104 | 105 | com.google.auto.service 106 | auto-service 107 | ${auto-service.version} 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /realm-test.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "test", 3 | "realm": "test", 4 | "notBefore": 0, 5 | "defaultSignatureAlgorithm": "RS256", 6 | "revokeRefreshToken": false, 7 | "refreshTokenMaxReuse": 0, 8 | "accessTokenLifespan": 300, 9 | "accessTokenLifespanForImplicitFlow": 900, 10 | "ssoSessionIdleTimeout": 1800, 11 | "ssoSessionMaxLifespan": 36000, 12 | "ssoSessionIdleTimeoutRememberMe": 0, 13 | "ssoSessionMaxLifespanRememberMe": 0, 14 | "offlineSessionIdleTimeout": 2592000, 15 | "offlineSessionMaxLifespanEnabled": false, 16 | "offlineSessionMaxLifespan": 5184000, 17 | "clientSessionIdleTimeout": 0, 18 | "clientSessionMaxLifespan": 0, 19 | "clientOfflineSessionIdleTimeout": 0, 20 | "clientOfflineSessionMaxLifespan": 0, 21 | "accessCodeLifespan": 60, 22 | "accessCodeLifespanUserAction": 300, 23 | "accessCodeLifespanLogin": 1800, 24 | "actionTokenGeneratedByAdminLifespan": 43200, 25 | "actionTokenGeneratedByUserLifespan": 300, 26 | "oauth2DeviceCodeLifespan": 600, 27 | "oauth2DevicePollingInterval": 5, 28 | "enabled": true, 29 | "sslRequired": "external", 30 | "registrationAllowed": false, 31 | "registrationEmailAsUsername": false, 32 | "rememberMe": false, 33 | "verifyEmail": false, 34 | "loginWithEmailAllowed": true, 35 | "duplicateEmailsAllowed": false, 36 | "resetPasswordAllowed": false, 37 | "editUsernameAllowed": false, 38 | "bruteForceProtected": false, 39 | "permanentLockout": false, 40 | "maxFailureWaitSeconds": 900, 41 | "minimumQuickLoginWaitSeconds": 60, 42 | "waitIncrementSeconds": 60, 43 | "quickLoginCheckMilliSeconds": 1000, 44 | "maxDeltaTimeSeconds": 43200, 45 | "failureFactor": 30, 46 | "defaultRole": { 47 | "id": "e464029a-ed71-4e6d-9008-4cf280045006", 48 | "name": "default-roles-test", 49 | "description": "${role_default-roles}", 50 | "composite": true, 51 | "clientRole": false, 52 | "containerId": "test" 53 | }, 54 | "requiredCredentials": [ 55 | "password" 56 | ], 57 | "otpPolicyType": "totp", 58 | "otpPolicyAlgorithm": "HmacSHA1", 59 | "otpPolicyInitialCounter": 0, 60 | "otpPolicyDigits": 6, 61 | "otpPolicyLookAheadWindow": 1, 62 | "otpPolicyPeriod": 30, 63 | "otpPolicyCodeReusable": false, 64 | "otpSupportedApplications": [ 65 | "totpAppGoogleName", 66 | "totpAppFreeOTPName" 67 | ], 68 | "webAuthnPolicyRpEntityName": "keycloak", 69 | "webAuthnPolicySignatureAlgorithms": [ 70 | "ES256" 71 | ], 72 | "webAuthnPolicyRpId": "", 73 | "webAuthnPolicyAttestationConveyancePreference": "not specified", 74 | "webAuthnPolicyAuthenticatorAttachment": "not specified", 75 | "webAuthnPolicyRequireResidentKey": "not specified", 76 | "webAuthnPolicyUserVerificationRequirement": "not specified", 77 | "webAuthnPolicyCreateTimeout": 0, 78 | "webAuthnPolicyAvoidSameAuthenticatorRegister": false, 79 | "webAuthnPolicyAcceptableAaguids": [], 80 | "webAuthnPolicyPasswordlessRpEntityName": "keycloak", 81 | "webAuthnPolicyPasswordlessSignatureAlgorithms": [ 82 | "ES256" 83 | ], 84 | "webAuthnPolicyPasswordlessRpId": "", 85 | "webAuthnPolicyPasswordlessAttestationConveyancePreference": "not specified", 86 | "webAuthnPolicyPasswordlessAuthenticatorAttachment": "not specified", 87 | "webAuthnPolicyPasswordlessRequireResidentKey": "not specified", 88 | "webAuthnPolicyPasswordlessUserVerificationRequirement": "not specified", 89 | "webAuthnPolicyPasswordlessCreateTimeout": 0, 90 | "webAuthnPolicyPasswordlessAvoidSameAuthenticatorRegister": false, 91 | "webAuthnPolicyPasswordlessAcceptableAaguids": [], 92 | "scopeMappings": [ 93 | { 94 | "clientScope": "offline_access", 95 | "roles": [ 96 | "offline_access" 97 | ] 98 | } 99 | ], 100 | "clientScopes": [ 101 | { 102 | "id": "2674b938-bf90-423a-9d9b-0d88997b43e1", 103 | "name": "email", 104 | "description": "OpenID Connect built-in scope: email", 105 | "protocol": "openid-connect", 106 | "attributes": { 107 | "include.in.token.scope": "true", 108 | "display.on.consent.screen": "true", 109 | "consent.screen.text": "${emailScopeConsentText}" 110 | }, 111 | "protocolMappers": [ 112 | { 113 | "id": "a9f5fd9e-329f-4c00-a2ff-4ae9b7abe895", 114 | "name": "email verified", 115 | "protocol": "openid-connect", 116 | "protocolMapper": "oidc-usermodel-property-mapper", 117 | "consentRequired": false, 118 | "config": { 119 | "userinfo.token.claim": "true", 120 | "user.attribute": "emailVerified", 121 | "id.token.claim": "true", 122 | "access.token.claim": "true", 123 | "claim.name": "email_verified", 124 | "jsonType.label": "boolean" 125 | } 126 | }, 127 | { 128 | "id": "05aae434-d298-4e24-8c0b-86b7dd19b32c", 129 | "name": "email", 130 | "protocol": "openid-connect", 131 | "protocolMapper": "oidc-usermodel-property-mapper", 132 | "consentRequired": false, 133 | "config": { 134 | "userinfo.token.claim": "true", 135 | "user.attribute": "email", 136 | "id.token.claim": "true", 137 | "access.token.claim": "true", 138 | "claim.name": "email", 139 | "jsonType.label": "String" 140 | } 141 | } 142 | ] 143 | }, 144 | { 145 | "id": "eda1e688-6478-42ec-ad91-4e330a14b41b", 146 | "name": "address", 147 | "description": "OpenID Connect built-in scope: address", 148 | "protocol": "openid-connect", 149 | "attributes": { 150 | "include.in.token.scope": "true", 151 | "display.on.consent.screen": "true", 152 | "consent.screen.text": "${addressScopeConsentText}" 153 | }, 154 | "protocolMappers": [ 155 | { 156 | "id": "5bb92ddd-d803-46de-ace3-0a0393c8ccdc", 157 | "name": "address", 158 | "protocol": "openid-connect", 159 | "protocolMapper": "oidc-address-mapper", 160 | "consentRequired": false, 161 | "config": { 162 | "user.attribute.formatted": "formatted", 163 | "user.attribute.country": "country", 164 | "user.attribute.postal_code": "postal_code", 165 | "userinfo.token.claim": "true", 166 | "user.attribute.street": "street", 167 | "id.token.claim": "true", 168 | "user.attribute.region": "region", 169 | "access.token.claim": "true", 170 | "user.attribute.locality": "locality" 171 | } 172 | } 173 | ] 174 | }, 175 | { 176 | "id": "88c24d65-b67c-4d4c-9076-7c6a59362a5c", 177 | "name": "offline_access", 178 | "description": "OpenID Connect built-in scope: offline_access", 179 | "protocol": "openid-connect", 180 | "attributes": { 181 | "consent.screen.text": "${offlineAccessScopeConsentText}", 182 | "display.on.consent.screen": "true" 183 | } 184 | }, 185 | { 186 | "id": "02c030f7-b861-4c86-8fbc-f6bf83bddd86", 187 | "name": "phone", 188 | "description": "OpenID Connect built-in scope: phone", 189 | "protocol": "openid-connect", 190 | "attributes": { 191 | "include.in.token.scope": "true", 192 | "display.on.consent.screen": "true", 193 | "consent.screen.text": "${phoneScopeConsentText}" 194 | }, 195 | "protocolMappers": [ 196 | { 197 | "id": "56da48d3-8791-4681-b240-0bda1eb74ac8", 198 | "name": "phone number", 199 | "protocol": "openid-connect", 200 | "protocolMapper": "oidc-usermodel-attribute-mapper", 201 | "consentRequired": false, 202 | "config": { 203 | "userinfo.token.claim": "true", 204 | "user.attribute": "phoneNumber", 205 | "id.token.claim": "true", 206 | "access.token.claim": "true", 207 | "claim.name": "phone_number", 208 | "jsonType.label": "String" 209 | } 210 | }, 211 | { 212 | "id": "2a427748-edcd-432a-9b23-a3cd099c1a8e", 213 | "name": "phone number verified", 214 | "protocol": "openid-connect", 215 | "protocolMapper": "oidc-usermodel-attribute-mapper", 216 | "consentRequired": false, 217 | "config": { 218 | "userinfo.token.claim": "true", 219 | "user.attribute": "phoneNumberVerified", 220 | "id.token.claim": "true", 221 | "access.token.claim": "true", 222 | "claim.name": "phone_number_verified", 223 | "jsonType.label": "boolean" 224 | } 225 | } 226 | ] 227 | }, 228 | { 229 | "id": "0f254851-30e9-4219-a7d9-15bc4087c6f3", 230 | "name": "microprofile-jwt", 231 | "description": "Microprofile - JWT built-in scope", 232 | "protocol": "openid-connect", 233 | "attributes": { 234 | "include.in.token.scope": "true", 235 | "display.on.consent.screen": "false" 236 | }, 237 | "protocolMappers": [ 238 | { 239 | "id": "01cf30c9-f63a-4233-8adc-c7240b9c74d8", 240 | "name": "groups", 241 | "protocol": "openid-connect", 242 | "protocolMapper": "oidc-usermodel-realm-role-mapper", 243 | "consentRequired": false, 244 | "config": { 245 | "multivalued": "true", 246 | "user.attribute": "foo", 247 | "id.token.claim": "true", 248 | "access.token.claim": "true", 249 | "claim.name": "groups", 250 | "jsonType.label": "String" 251 | } 252 | }, 253 | { 254 | "id": "55a3853a-b468-48ed-9040-62f10b50edd7", 255 | "name": "upn", 256 | "protocol": "openid-connect", 257 | "protocolMapper": "oidc-usermodel-property-mapper", 258 | "consentRequired": false, 259 | "config": { 260 | "userinfo.token.claim": "true", 261 | "user.attribute": "username", 262 | "id.token.claim": "true", 263 | "access.token.claim": "true", 264 | "claim.name": "upn", 265 | "jsonType.label": "String" 266 | } 267 | } 268 | ] 269 | }, 270 | { 271 | "id": "b8454516-d7e6-4741-8a0f-82bb81d634be", 272 | "name": "role_list", 273 | "description": "SAML role list", 274 | "protocol": "saml", 275 | "attributes": { 276 | "consent.screen.text": "${samlRoleListScopeConsentText}", 277 | "display.on.consent.screen": "true" 278 | }, 279 | "protocolMappers": [ 280 | { 281 | "id": "7ce9f70e-0798-454c-b2e6-809296b3b5e8", 282 | "name": "role list", 283 | "protocol": "saml", 284 | "protocolMapper": "saml-role-list-mapper", 285 | "consentRequired": false, 286 | "config": { 287 | "single": "false", 288 | "attribute.nameformat": "Basic", 289 | "attribute.name": "Role" 290 | } 291 | } 292 | ] 293 | }, 294 | { 295 | "id": "cf5aeeec-831f-41ef-9ea7-3459258ab6f5", 296 | "name": "profile", 297 | "description": "OpenID Connect built-in scope: profile", 298 | "protocol": "openid-connect", 299 | "attributes": { 300 | "include.in.token.scope": "true", 301 | "display.on.consent.screen": "true", 302 | "consent.screen.text": "${profileScopeConsentText}" 303 | }, 304 | "protocolMappers": [ 305 | { 306 | "id": "892dce2d-305a-4bdf-b13f-f80c7985f42e", 307 | "name": "given name", 308 | "protocol": "openid-connect", 309 | "protocolMapper": "oidc-usermodel-property-mapper", 310 | "consentRequired": false, 311 | "config": { 312 | "userinfo.token.claim": "true", 313 | "user.attribute": "firstName", 314 | "id.token.claim": "true", 315 | "access.token.claim": "true", 316 | "claim.name": "given_name", 317 | "jsonType.label": "String" 318 | } 319 | }, 320 | { 321 | "id": "278a87e8-c1c2-4e82-9cc6-07654c201bdd", 322 | "name": "full name", 323 | "protocol": "openid-connect", 324 | "protocolMapper": "oidc-full-name-mapper", 325 | "consentRequired": false, 326 | "config": { 327 | "id.token.claim": "true", 328 | "access.token.claim": "true", 329 | "userinfo.token.claim": "true" 330 | } 331 | }, 332 | { 333 | "id": "cd27c0d5-1960-4d81-ae2c-ea6c56ec2144", 334 | "name": "gender", 335 | "protocol": "openid-connect", 336 | "protocolMapper": "oidc-usermodel-attribute-mapper", 337 | "consentRequired": false, 338 | "config": { 339 | "userinfo.token.claim": "true", 340 | "user.attribute": "gender", 341 | "id.token.claim": "true", 342 | "access.token.claim": "true", 343 | "claim.name": "gender", 344 | "jsonType.label": "String" 345 | } 346 | }, 347 | { 348 | "id": "1ff1679a-521d-4520-9fe4-58d78ca6e622", 349 | "name": "picture", 350 | "protocol": "openid-connect", 351 | "protocolMapper": "oidc-usermodel-attribute-mapper", 352 | "consentRequired": false, 353 | "config": { 354 | "userinfo.token.claim": "true", 355 | "user.attribute": "picture", 356 | "id.token.claim": "true", 357 | "access.token.claim": "true", 358 | "claim.name": "picture", 359 | "jsonType.label": "String" 360 | } 361 | }, 362 | { 363 | "id": "9f551e36-4734-460c-aebf-c7359f97b730", 364 | "name": "website", 365 | "protocol": "openid-connect", 366 | "protocolMapper": "oidc-usermodel-attribute-mapper", 367 | "consentRequired": false, 368 | "config": { 369 | "userinfo.token.claim": "true", 370 | "user.attribute": "website", 371 | "id.token.claim": "true", 372 | "access.token.claim": "true", 373 | "claim.name": "website", 374 | "jsonType.label": "String" 375 | } 376 | }, 377 | { 378 | "id": "f872778a-4d34-4bbb-96f9-1c0ba3d9548b", 379 | "name": "updated at", 380 | "protocol": "openid-connect", 381 | "protocolMapper": "oidc-usermodel-attribute-mapper", 382 | "consentRequired": false, 383 | "config": { 384 | "userinfo.token.claim": "true", 385 | "user.attribute": "updatedAt", 386 | "id.token.claim": "true", 387 | "access.token.claim": "true", 388 | "claim.name": "updated_at", 389 | "jsonType.label": "long" 390 | } 391 | }, 392 | { 393 | "id": "024e5e36-2cbc-429d-947e-f6c7318e3cb5", 394 | "name": "profile", 395 | "protocol": "openid-connect", 396 | "protocolMapper": "oidc-usermodel-attribute-mapper", 397 | "consentRequired": false, 398 | "config": { 399 | "userinfo.token.claim": "true", 400 | "user.attribute": "profile", 401 | "id.token.claim": "true", 402 | "access.token.claim": "true", 403 | "claim.name": "profile", 404 | "jsonType.label": "String" 405 | } 406 | }, 407 | { 408 | "id": "e6ed1c95-5093-4215-9a1f-fb025bc951a4", 409 | "name": "family name", 410 | "protocol": "openid-connect", 411 | "protocolMapper": "oidc-usermodel-property-mapper", 412 | "consentRequired": false, 413 | "config": { 414 | "userinfo.token.claim": "true", 415 | "user.attribute": "lastName", 416 | "id.token.claim": "true", 417 | "access.token.claim": "true", 418 | "claim.name": "family_name", 419 | "jsonType.label": "String" 420 | } 421 | }, 422 | { 423 | "id": "b7c65519-12b7-4ac5-8249-a71642c33de2", 424 | "name": "zoneinfo", 425 | "protocol": "openid-connect", 426 | "protocolMapper": "oidc-usermodel-attribute-mapper", 427 | "consentRequired": false, 428 | "config": { 429 | "userinfo.token.claim": "true", 430 | "user.attribute": "zoneinfo", 431 | "id.token.claim": "true", 432 | "access.token.claim": "true", 433 | "claim.name": "zoneinfo", 434 | "jsonType.label": "String" 435 | } 436 | }, 437 | { 438 | "id": "f57b5056-d6dc-415d-9059-10e8f16ba349", 439 | "name": "username", 440 | "protocol": "openid-connect", 441 | "protocolMapper": "oidc-usermodel-property-mapper", 442 | "consentRequired": false, 443 | "config": { 444 | "userinfo.token.claim": "true", 445 | "user.attribute": "username", 446 | "id.token.claim": "true", 447 | "access.token.claim": "true", 448 | "claim.name": "preferred_username", 449 | "jsonType.label": "String" 450 | } 451 | }, 452 | { 453 | "id": "73834ba2-0ccd-49d1-bbf6-d4dcbbd17cbc", 454 | "name": "locale", 455 | "protocol": "openid-connect", 456 | "protocolMapper": "oidc-usermodel-attribute-mapper", 457 | "consentRequired": false, 458 | "config": { 459 | "userinfo.token.claim": "true", 460 | "user.attribute": "locale", 461 | "id.token.claim": "true", 462 | "access.token.claim": "true", 463 | "claim.name": "locale", 464 | "jsonType.label": "String" 465 | } 466 | }, 467 | { 468 | "id": "792db506-689e-45c3-ba03-d6a2dfbd7461", 469 | "name": "middle name", 470 | "protocol": "openid-connect", 471 | "protocolMapper": "oidc-usermodel-attribute-mapper", 472 | "consentRequired": false, 473 | "config": { 474 | "userinfo.token.claim": "true", 475 | "user.attribute": "middleName", 476 | "id.token.claim": "true", 477 | "access.token.claim": "true", 478 | "claim.name": "middle_name", 479 | "jsonType.label": "String" 480 | } 481 | }, 482 | { 483 | "id": "bf52e213-1d35-4569-87c0-46f9261ee789", 484 | "name": "nickname", 485 | "protocol": "openid-connect", 486 | "protocolMapper": "oidc-usermodel-attribute-mapper", 487 | "consentRequired": false, 488 | "config": { 489 | "userinfo.token.claim": "true", 490 | "user.attribute": "nickname", 491 | "id.token.claim": "true", 492 | "access.token.claim": "true", 493 | "claim.name": "nickname", 494 | "jsonType.label": "String" 495 | } 496 | }, 497 | { 498 | "id": "83b3d8f9-3fe8-4866-aa61-b3e41d33c87b", 499 | "name": "birthdate", 500 | "protocol": "openid-connect", 501 | "protocolMapper": "oidc-usermodel-attribute-mapper", 502 | "consentRequired": false, 503 | "config": { 504 | "userinfo.token.claim": "true", 505 | "user.attribute": "birthdate", 506 | "id.token.claim": "true", 507 | "access.token.claim": "true", 508 | "claim.name": "birthdate", 509 | "jsonType.label": "String" 510 | } 511 | } 512 | ] 513 | }, 514 | { 515 | "id": "24498838-3746-42e9-95ee-0debf7474b1c", 516 | "name": "web-origins", 517 | "description": "OpenID Connect scope for add allowed web origins to the access token", 518 | "protocol": "openid-connect", 519 | "attributes": { 520 | "include.in.token.scope": "false", 521 | "display.on.consent.screen": "false", 522 | "consent.screen.text": "" 523 | }, 524 | "protocolMappers": [ 525 | { 526 | "id": "9aacd747-914f-43b8-96ab-639133e34ef9", 527 | "name": "allowed web origins", 528 | "protocol": "openid-connect", 529 | "protocolMapper": "oidc-allowed-origins-mapper", 530 | "consentRequired": false, 531 | "config": {} 532 | } 533 | ] 534 | }, 535 | { 536 | "id": "3d7a92ed-799a-4da7-8501-5cf77112a9ed", 537 | "name": "roles", 538 | "description": "OpenID Connect scope for add user roles to the access token", 539 | "protocol": "openid-connect", 540 | "attributes": { 541 | "include.in.token.scope": "false", 542 | "display.on.consent.screen": "true", 543 | "consent.screen.text": "${rolesScopeConsentText}" 544 | }, 545 | "protocolMappers": [ 546 | { 547 | "id": "78399528-e2d5-458c-9d8a-500381d70592", 548 | "name": "audience resolve", 549 | "protocol": "openid-connect", 550 | "protocolMapper": "oidc-audience-resolve-mapper", 551 | "consentRequired": false, 552 | "config": {} 553 | }, 554 | { 555 | "id": "557f8afa-7a6b-4119-a5eb-81b508e69c60", 556 | "name": "realm roles", 557 | "protocol": "openid-connect", 558 | "protocolMapper": "oidc-usermodel-realm-role-mapper", 559 | "consentRequired": false, 560 | "config": { 561 | "user.attribute": "foo", 562 | "access.token.claim": "true", 563 | "claim.name": "realm_access.roles", 564 | "jsonType.label": "String", 565 | "multivalued": "true" 566 | } 567 | }, 568 | { 569 | "id": "4a117cc0-a037-4ee8-be7b-68334274d240", 570 | "name": "client roles", 571 | "protocol": "openid-connect", 572 | "protocolMapper": "oidc-usermodel-client-role-mapper", 573 | "consentRequired": false, 574 | "config": { 575 | "user.attribute": "foo", 576 | "access.token.claim": "true", 577 | "claim.name": "resource_access.${client_id}.roles", 578 | "jsonType.label": "String", 579 | "multivalued": "true" 580 | } 581 | } 582 | ] 583 | }, 584 | { 585 | "id": "bba0a258-82de-45df-be7f-7140f6ec0750", 586 | "name": "acr", 587 | "description": "OpenID Connect scope for add acr (authentication context class reference) to the token", 588 | "protocol": "openid-connect", 589 | "attributes": { 590 | "include.in.token.scope": "false", 591 | "display.on.consent.screen": "false" 592 | }, 593 | "protocolMappers": [ 594 | { 595 | "id": "d6ebf437-8857-4a4b-aa0c-bc023b2c560a", 596 | "name": "acr loa level", 597 | "protocol": "openid-connect", 598 | "protocolMapper": "oidc-acr-mapper", 599 | "consentRequired": false, 600 | "config": { 601 | "id.token.claim": "true", 602 | "access.token.claim": "true" 603 | } 604 | } 605 | ] 606 | } 607 | ], 608 | "defaultDefaultClientScopes": [ 609 | "role_list", 610 | "profile", 611 | "email", 612 | "roles", 613 | "web-origins", 614 | "acr" 615 | ], 616 | "defaultOptionalClientScopes": [ 617 | "offline_access", 618 | "address", 619 | "phone", 620 | "microprofile-jwt" 621 | ], 622 | "browserSecurityHeaders": { 623 | "contentSecurityPolicyReportOnly": "", 624 | "xContentTypeOptions": "nosniff", 625 | "xRobotsTag": "none", 626 | "xFrameOptions": "SAMEORIGIN", 627 | "contentSecurityPolicy": "frame-src 'self'; frame-ancestors 'self'; object-src 'none';", 628 | "xXSSProtection": "1; mode=block", 629 | "strictTransportSecurity": "max-age=31536000; includeSubDomains" 630 | }, 631 | "smtpServer": {}, 632 | "eventsEnabled": false, 633 | "eventsListeners": [ 634 | "jboss-logging" 635 | ], 636 | "enabledEventTypes": [], 637 | "adminEventsEnabled": false, 638 | "adminEventsDetailsEnabled": false, 639 | "identityProviders": [], 640 | "identityProviderMappers": [], 641 | "components": { 642 | "org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy": [ 643 | { 644 | "id": "f3ceed28-31c3-41a0-bb5e-fba5b046bc2c", 645 | "name": "Trusted Hosts", 646 | "providerId": "trusted-hosts", 647 | "subType": "anonymous", 648 | "subComponents": {}, 649 | "config": { 650 | "host-sending-registration-request-must-match": [ 651 | "true" 652 | ], 653 | "client-uris-must-match": [ 654 | "true" 655 | ] 656 | } 657 | }, 658 | { 659 | "id": "328d97b5-2cef-4b4b-b357-955029095278", 660 | "name": "Allowed Client Scopes", 661 | "providerId": "allowed-client-templates", 662 | "subType": "anonymous", 663 | "subComponents": {}, 664 | "config": { 665 | "allow-default-scopes": [ 666 | "true" 667 | ] 668 | } 669 | }, 670 | { 671 | "id": "c279b340-02bc-429f-9c96-61760867d0a8", 672 | "name": "Allowed Protocol Mapper Types", 673 | "providerId": "allowed-protocol-mappers", 674 | "subType": "authenticated", 675 | "subComponents": {}, 676 | "config": { 677 | "allowed-protocol-mapper-types": [ 678 | "oidc-full-name-mapper", 679 | "saml-role-list-mapper", 680 | "oidc-usermodel-property-mapper", 681 | "oidc-address-mapper", 682 | "oidc-usermodel-attribute-mapper", 683 | "saml-user-attribute-mapper", 684 | "oidc-sha256-pairwise-sub-mapper", 685 | "saml-user-property-mapper" 686 | ] 687 | } 688 | }, 689 | { 690 | "id": "5f47ddf4-d1db-40e8-91ba-b0ab03b43561", 691 | "name": "Consent Required", 692 | "providerId": "consent-required", 693 | "subType": "anonymous", 694 | "subComponents": {}, 695 | "config": {} 696 | }, 697 | { 698 | "id": "60048490-adff-4d8c-9e7c-f238b95d1d46", 699 | "name": "Max Clients Limit", 700 | "providerId": "max-clients", 701 | "subType": "anonymous", 702 | "subComponents": {}, 703 | "config": { 704 | "max-clients": [ 705 | "200" 706 | ] 707 | } 708 | }, 709 | { 710 | "id": "78bcdc8d-fe0c-4fea-a042-098eeaac83bd", 711 | "name": "Allowed Protocol Mapper Types", 712 | "providerId": "allowed-protocol-mappers", 713 | "subType": "anonymous", 714 | "subComponents": {}, 715 | "config": { 716 | "allowed-protocol-mapper-types": [ 717 | "oidc-usermodel-attribute-mapper", 718 | "oidc-address-mapper", 719 | "saml-user-property-mapper", 720 | "oidc-sha256-pairwise-sub-mapper", 721 | "oidc-full-name-mapper", 722 | "oidc-usermodel-property-mapper", 723 | "saml-user-attribute-mapper", 724 | "saml-role-list-mapper" 725 | ] 726 | } 727 | }, 728 | { 729 | "id": "eb48fd49-d7ab-416e-af11-1b36a878dea3", 730 | "name": "Full Scope Disabled", 731 | "providerId": "scope", 732 | "subType": "anonymous", 733 | "subComponents": {}, 734 | "config": {} 735 | }, 736 | { 737 | "id": "550efe3e-7774-4e84-ba31-6133fc6f255a", 738 | "name": "Allowed Client Scopes", 739 | "providerId": "allowed-client-templates", 740 | "subType": "authenticated", 741 | "subComponents": {}, 742 | "config": { 743 | "allow-default-scopes": [ 744 | "true" 745 | ] 746 | } 747 | } 748 | ], 749 | "org.keycloak.keys.KeyProvider": [ 750 | { 751 | "id": "89cb8fd7-53e5-486e-a642-8cdfe2324232", 752 | "name": "rsa-enc-generated", 753 | "providerId": "rsa-enc-generated", 754 | "subComponents": {}, 755 | "config": { 756 | "priority": [ 757 | "100" 758 | ], 759 | "algorithm": [ 760 | "RSA-OAEP" 761 | ] 762 | } 763 | }, 764 | { 765 | "id": "fcbd8747-ebb5-46d6-8b75-134f7d3dc687", 766 | "name": "hmac-generated", 767 | "providerId": "hmac-generated", 768 | "subComponents": {}, 769 | "config": { 770 | "priority": [ 771 | "100" 772 | ], 773 | "algorithm": [ 774 | "HS256" 775 | ] 776 | } 777 | }, 778 | { 779 | "id": "aba3dec0-109d-4d31-af85-4a3df71853b9", 780 | "name": "aes-generated", 781 | "providerId": "aes-generated", 782 | "subComponents": {}, 783 | "config": { 784 | "priority": [ 785 | "100" 786 | ] 787 | } 788 | }, 789 | { 790 | "id": "f7701067-241f-424d-bece-62bd86422b81", 791 | "name": "rsa-generated", 792 | "providerId": "rsa-generated", 793 | "subComponents": {}, 794 | "config": { 795 | "priority": [ 796 | "100" 797 | ] 798 | } 799 | } 800 | ] 801 | }, 802 | "internationalizationEnabled": false, 803 | "supportedLocales": [], 804 | "authenticationFlows": [ 805 | { 806 | "id": "a409ba4a-cfa5-4b8f-ba2f-fe7031a7c80b", 807 | "alias": "2FA - Browser", 808 | "description": "browser based authentication", 809 | "providerId": "basic-flow", 810 | "topLevel": true, 811 | "builtIn": false, 812 | "authenticationExecutions": [ 813 | { 814 | "authenticator": "auth-cookie", 815 | "authenticatorFlow": false, 816 | "requirement": "ALTERNATIVE", 817 | "priority": 10, 818 | "autheticatorFlow": false, 819 | "userSetupAllowed": false 820 | }, 821 | { 822 | "authenticator": "auth-spnego", 823 | "authenticatorFlow": false, 824 | "requirement": "DISABLED", 825 | "priority": 20, 826 | "autheticatorFlow": false, 827 | "userSetupAllowed": false 828 | }, 829 | { 830 | "authenticator": "identity-provider-redirector", 831 | "authenticatorFlow": false, 832 | "requirement": "ALTERNATIVE", 833 | "priority": 25, 834 | "autheticatorFlow": false, 835 | "userSetupAllowed": false 836 | }, 837 | { 838 | "authenticatorFlow": true, 839 | "requirement": "ALTERNATIVE", 840 | "priority": 30, 841 | "autheticatorFlow": true, 842 | "flowAlias": "2FA - Browser forms", 843 | "userSetupAllowed": false 844 | } 845 | ] 846 | }, 847 | { 848 | "id": "7bebcc18-315c-4a20-a073-6cd997333680", 849 | "alias": "2FA - Browser Browser - Conditional OTP", 850 | "description": "Flow to determine if the OTP is required for the authentication", 851 | "providerId": "basic-flow", 852 | "topLevel": false, 853 | "builtIn": false, 854 | "authenticationExecutions": [ 855 | { 856 | "authenticatorConfig": "2FA - Browser Browser - Conditional OTP - Device NOT trusted", 857 | "authenticator": "trusted-device-condition", 858 | "authenticatorFlow": false, 859 | "requirement": "REQUIRED", 860 | "priority": 10, 861 | "autheticatorFlow": false, 862 | "userSetupAllowed": false 863 | }, 864 | { 865 | "authenticatorConfig": "2FA - Browser Browser - Conditional OTP - Credential configured", 866 | "authenticator": "configured-credential-condition", 867 | "authenticatorFlow": false, 868 | "requirement": "REQUIRED", 869 | "priority": 20, 870 | "autheticatorFlow": false, 871 | "userSetupAllowed": false 872 | }, 873 | { 874 | "authenticatorFlow": true, 875 | "requirement": "REQUIRED", 876 | "priority": 21, 877 | "autheticatorFlow": true, 878 | "flowAlias": "2FA - Browser Browser - Conditional OTP - 2FA", 879 | "userSetupAllowed": false 880 | }, 881 | { 882 | "authenticatorConfig": "2FA - Browser Browser - Conditional OTP - Register Trusted Device", 883 | "authenticator": "trusted-device-authenticator", 884 | "authenticatorFlow": false, 885 | "requirement": "REQUIRED", 886 | "priority": 22, 887 | "autheticatorFlow": false, 888 | "userSetupAllowed": false 889 | } 890 | ] 891 | }, 892 | { 893 | "id": "171a7033-8859-4110-9d22-b84d9ae28b68", 894 | "alias": "2FA - Browser Browser - Conditional OTP - 2FA", 895 | "description": "", 896 | "providerId": "basic-flow", 897 | "topLevel": false, 898 | "builtIn": false, 899 | "authenticationExecutions": [ 900 | { 901 | "authenticator": "webauthn-authenticator", 902 | "authenticatorFlow": false, 903 | "requirement": "ALTERNATIVE", 904 | "priority": 0, 905 | "autheticatorFlow": false, 906 | "userSetupAllowed": false 907 | }, 908 | { 909 | "authenticator": "auth-otp-form", 910 | "authenticatorFlow": false, 911 | "requirement": "ALTERNATIVE", 912 | "priority": 1, 913 | "autheticatorFlow": false, 914 | "userSetupAllowed": false 915 | } 916 | ] 917 | }, 918 | { 919 | "id": "7614d81f-e92c-47cc-9cb9-b1e8b889a44e", 920 | "alias": "2FA - Browser forms", 921 | "description": "Username, password, otp and other auth forms.", 922 | "providerId": "basic-flow", 923 | "topLevel": false, 924 | "builtIn": false, 925 | "authenticationExecutions": [ 926 | { 927 | "authenticator": "auth-username-password-form", 928 | "authenticatorFlow": false, 929 | "requirement": "REQUIRED", 930 | "priority": 10, 931 | "autheticatorFlow": false, 932 | "userSetupAllowed": false 933 | }, 934 | { 935 | "authenticatorFlow": true, 936 | "requirement": "CONDITIONAL", 937 | "priority": 20, 938 | "autheticatorFlow": true, 939 | "flowAlias": "2FA - Browser Browser - Conditional OTP", 940 | "userSetupAllowed": false 941 | } 942 | ] 943 | }, 944 | { 945 | "id": "20578d23-5a68-4b84-81b4-9cc2d87a68fc", 946 | "alias": "2FA - direct grant", 947 | "description": "OpenID Connect Resource Owner Grant", 948 | "providerId": "basic-flow", 949 | "topLevel": true, 950 | "builtIn": false, 951 | "authenticationExecutions": [ 952 | { 953 | "authenticator": "direct-grant-validate-username", 954 | "authenticatorFlow": false, 955 | "requirement": "REQUIRED", 956 | "priority": 10, 957 | "autheticatorFlow": false, 958 | "userSetupAllowed": false 959 | }, 960 | { 961 | "authenticator": "direct-grant-validate-password", 962 | "authenticatorFlow": false, 963 | "requirement": "REQUIRED", 964 | "priority": 20, 965 | "autheticatorFlow": false, 966 | "userSetupAllowed": false 967 | }, 968 | { 969 | "authenticatorFlow": true, 970 | "requirement": "CONDITIONAL", 971 | "priority": 30, 972 | "autheticatorFlow": true, 973 | "flowAlias": "2FA - direct grant Direct Grant - Conditional OTP", 974 | "userSetupAllowed": false 975 | } 976 | ] 977 | }, 978 | { 979 | "id": "aff6115e-4284-44bd-b244-87a34a28fa68", 980 | "alias": "2FA - direct grant Direct Grant - Conditional OTP", 981 | "description": "Flow to determine if the OTP is required for the authentication", 982 | "providerId": "basic-flow", 983 | "topLevel": false, 984 | "builtIn": false, 985 | "authenticationExecutions": [ 986 | { 987 | "authenticatorConfig": "2FA - Direct Grant Direct Grant - Conditional OTP - Credential configured", 988 | "authenticator": "configured-credential-condition", 989 | "authenticatorFlow": false, 990 | "requirement": "REQUIRED", 991 | "priority": 20, 992 | "autheticatorFlow": false, 993 | "userSetupAllowed": false 994 | }, 995 | { 996 | "authenticator": "direct-grant-validate-otp", 997 | "authenticatorFlow": false, 998 | "requirement": "REQUIRED", 999 | "priority": 21, 1000 | "autheticatorFlow": false, 1001 | "userSetupAllowed": false 1002 | } 1003 | ] 1004 | }, 1005 | { 1006 | "id": "199fe845-e6a5-4ea9-9d51-573fd6fd2ca7", 1007 | "alias": "Account verification options", 1008 | "description": "Method with which to verity the existing account", 1009 | "providerId": "basic-flow", 1010 | "topLevel": false, 1011 | "builtIn": true, 1012 | "authenticationExecutions": [ 1013 | { 1014 | "authenticator": "idp-email-verification", 1015 | "authenticatorFlow": false, 1016 | "requirement": "ALTERNATIVE", 1017 | "priority": 10, 1018 | "autheticatorFlow": false, 1019 | "userSetupAllowed": false 1020 | }, 1021 | { 1022 | "authenticatorFlow": true, 1023 | "requirement": "ALTERNATIVE", 1024 | "priority": 20, 1025 | "autheticatorFlow": true, 1026 | "flowAlias": "Verify Existing Account by Re-authentication", 1027 | "userSetupAllowed": false 1028 | } 1029 | ] 1030 | }, 1031 | { 1032 | "id": "21645267-d4d8-4aab-958b-50aef5a6f226", 1033 | "alias": "Authentication Options", 1034 | "description": "Authentication options.", 1035 | "providerId": "basic-flow", 1036 | "topLevel": false, 1037 | "builtIn": true, 1038 | "authenticationExecutions": [ 1039 | { 1040 | "authenticator": "basic-auth", 1041 | "authenticatorFlow": false, 1042 | "requirement": "REQUIRED", 1043 | "priority": 10, 1044 | "autheticatorFlow": false, 1045 | "userSetupAllowed": false 1046 | }, 1047 | { 1048 | "authenticator": "basic-auth-otp", 1049 | "authenticatorFlow": false, 1050 | "requirement": "DISABLED", 1051 | "priority": 20, 1052 | "autheticatorFlow": false, 1053 | "userSetupAllowed": false 1054 | }, 1055 | { 1056 | "authenticator": "auth-spnego", 1057 | "authenticatorFlow": false, 1058 | "requirement": "DISABLED", 1059 | "priority": 30, 1060 | "autheticatorFlow": false, 1061 | "userSetupAllowed": false 1062 | } 1063 | ] 1064 | }, 1065 | { 1066 | "id": "3b062bba-a278-4e3b-bb90-2c9baba2b2ad", 1067 | "alias": "Browser - Conditional OTP", 1068 | "description": "Flow to determine if the OTP is required for the authentication", 1069 | "providerId": "basic-flow", 1070 | "topLevel": false, 1071 | "builtIn": true, 1072 | "authenticationExecutions": [ 1073 | { 1074 | "authenticator": "conditional-user-configured", 1075 | "authenticatorFlow": false, 1076 | "requirement": "REQUIRED", 1077 | "priority": 10, 1078 | "autheticatorFlow": false, 1079 | "userSetupAllowed": false 1080 | }, 1081 | { 1082 | "authenticator": "auth-otp-form", 1083 | "authenticatorFlow": false, 1084 | "requirement": "REQUIRED", 1085 | "priority": 20, 1086 | "autheticatorFlow": false, 1087 | "userSetupAllowed": false 1088 | } 1089 | ] 1090 | }, 1091 | { 1092 | "id": "84608792-2ddb-4205-82f6-62edee969a18", 1093 | "alias": "Direct Grant - Conditional OTP", 1094 | "description": "Flow to determine if the OTP is required for the authentication", 1095 | "providerId": "basic-flow", 1096 | "topLevel": false, 1097 | "builtIn": true, 1098 | "authenticationExecutions": [ 1099 | { 1100 | "authenticator": "conditional-user-configured", 1101 | "authenticatorFlow": false, 1102 | "requirement": "REQUIRED", 1103 | "priority": 10, 1104 | "autheticatorFlow": false, 1105 | "userSetupAllowed": false 1106 | }, 1107 | { 1108 | "authenticator": "direct-grant-validate-otp", 1109 | "authenticatorFlow": false, 1110 | "requirement": "REQUIRED", 1111 | "priority": 20, 1112 | "autheticatorFlow": false, 1113 | "userSetupAllowed": false 1114 | } 1115 | ] 1116 | }, 1117 | { 1118 | "id": "1613f642-50b2-4ecb-aded-548c9eabf357", 1119 | "alias": "First broker login - Conditional OTP", 1120 | "description": "Flow to determine if the OTP is required for the authentication", 1121 | "providerId": "basic-flow", 1122 | "topLevel": false, 1123 | "builtIn": true, 1124 | "authenticationExecutions": [ 1125 | { 1126 | "authenticator": "conditional-user-configured", 1127 | "authenticatorFlow": false, 1128 | "requirement": "REQUIRED", 1129 | "priority": 10, 1130 | "autheticatorFlow": false, 1131 | "userSetupAllowed": false 1132 | }, 1133 | { 1134 | "authenticator": "auth-otp-form", 1135 | "authenticatorFlow": false, 1136 | "requirement": "REQUIRED", 1137 | "priority": 20, 1138 | "autheticatorFlow": false, 1139 | "userSetupAllowed": false 1140 | } 1141 | ] 1142 | }, 1143 | { 1144 | "id": "3d047742-6ed6-40ec-9505-9f931f6f4323", 1145 | "alias": "Handle Existing Account", 1146 | "description": "Handle what to do if there is existing account with same email/username like authenticated identity provider", 1147 | "providerId": "basic-flow", 1148 | "topLevel": false, 1149 | "builtIn": true, 1150 | "authenticationExecutions": [ 1151 | { 1152 | "authenticator": "idp-confirm-link", 1153 | "authenticatorFlow": false, 1154 | "requirement": "REQUIRED", 1155 | "priority": 10, 1156 | "autheticatorFlow": false, 1157 | "userSetupAllowed": false 1158 | }, 1159 | { 1160 | "authenticatorFlow": true, 1161 | "requirement": "REQUIRED", 1162 | "priority": 20, 1163 | "autheticatorFlow": true, 1164 | "flowAlias": "Account verification options", 1165 | "userSetupAllowed": false 1166 | } 1167 | ] 1168 | }, 1169 | { 1170 | "id": "7209191e-0058-4814-9be4-055d941705e6", 1171 | "alias": "Reset - Conditional OTP", 1172 | "description": "Flow to determine if the OTP should be reset or not. Set to REQUIRED to force.", 1173 | "providerId": "basic-flow", 1174 | "topLevel": false, 1175 | "builtIn": true, 1176 | "authenticationExecutions": [ 1177 | { 1178 | "authenticator": "conditional-user-configured", 1179 | "authenticatorFlow": false, 1180 | "requirement": "REQUIRED", 1181 | "priority": 10, 1182 | "autheticatorFlow": false, 1183 | "userSetupAllowed": false 1184 | }, 1185 | { 1186 | "authenticator": "reset-otp", 1187 | "authenticatorFlow": false, 1188 | "requirement": "REQUIRED", 1189 | "priority": 20, 1190 | "autheticatorFlow": false, 1191 | "userSetupAllowed": false 1192 | } 1193 | ] 1194 | }, 1195 | { 1196 | "id": "edfef15a-5290-426e-bb74-4c6c78cd2c4c", 1197 | "alias": "User creation or linking", 1198 | "description": "Flow for the existing/non-existing user alternatives", 1199 | "providerId": "basic-flow", 1200 | "topLevel": false, 1201 | "builtIn": true, 1202 | "authenticationExecutions": [ 1203 | { 1204 | "authenticatorConfig": "create unique user config", 1205 | "authenticator": "idp-create-user-if-unique", 1206 | "authenticatorFlow": false, 1207 | "requirement": "ALTERNATIVE", 1208 | "priority": 10, 1209 | "autheticatorFlow": false, 1210 | "userSetupAllowed": false 1211 | }, 1212 | { 1213 | "authenticatorFlow": true, 1214 | "requirement": "ALTERNATIVE", 1215 | "priority": 20, 1216 | "autheticatorFlow": true, 1217 | "flowAlias": "Handle Existing Account", 1218 | "userSetupAllowed": false 1219 | } 1220 | ] 1221 | }, 1222 | { 1223 | "id": "60b96749-6c28-4d23-acbf-2e977f476b2e", 1224 | "alias": "Verify Existing Account by Re-authentication", 1225 | "description": "Reauthentication of existing account", 1226 | "providerId": "basic-flow", 1227 | "topLevel": false, 1228 | "builtIn": true, 1229 | "authenticationExecutions": [ 1230 | { 1231 | "authenticator": "idp-username-password-form", 1232 | "authenticatorFlow": false, 1233 | "requirement": "REQUIRED", 1234 | "priority": 10, 1235 | "autheticatorFlow": false, 1236 | "userSetupAllowed": false 1237 | }, 1238 | { 1239 | "authenticatorFlow": true, 1240 | "requirement": "CONDITIONAL", 1241 | "priority": 20, 1242 | "autheticatorFlow": true, 1243 | "flowAlias": "First broker login - Conditional OTP", 1244 | "userSetupAllowed": false 1245 | } 1246 | ] 1247 | }, 1248 | { 1249 | "id": "e5e5c68c-866f-4e8c-841e-4c62a27f9da8", 1250 | "alias": "browser", 1251 | "description": "browser based authentication", 1252 | "providerId": "basic-flow", 1253 | "topLevel": true, 1254 | "builtIn": true, 1255 | "authenticationExecutions": [ 1256 | { 1257 | "authenticator": "auth-cookie", 1258 | "authenticatorFlow": false, 1259 | "requirement": "ALTERNATIVE", 1260 | "priority": 10, 1261 | "autheticatorFlow": false, 1262 | "userSetupAllowed": false 1263 | }, 1264 | { 1265 | "authenticator": "auth-spnego", 1266 | "authenticatorFlow": false, 1267 | "requirement": "DISABLED", 1268 | "priority": 20, 1269 | "autheticatorFlow": false, 1270 | "userSetupAllowed": false 1271 | }, 1272 | { 1273 | "authenticator": "identity-provider-redirector", 1274 | "authenticatorFlow": false, 1275 | "requirement": "ALTERNATIVE", 1276 | "priority": 25, 1277 | "autheticatorFlow": false, 1278 | "userSetupAllowed": false 1279 | }, 1280 | { 1281 | "authenticatorFlow": true, 1282 | "requirement": "ALTERNATIVE", 1283 | "priority": 30, 1284 | "autheticatorFlow": true, 1285 | "flowAlias": "forms", 1286 | "userSetupAllowed": false 1287 | } 1288 | ] 1289 | }, 1290 | { 1291 | "id": "e1ed05d8-c46d-4828-95e2-a4567318a9d1", 1292 | "alias": "clients", 1293 | "description": "Base authentication for clients", 1294 | "providerId": "client-flow", 1295 | "topLevel": true, 1296 | "builtIn": true, 1297 | "authenticationExecutions": [ 1298 | { 1299 | "authenticator": "client-secret", 1300 | "authenticatorFlow": false, 1301 | "requirement": "ALTERNATIVE", 1302 | "priority": 10, 1303 | "autheticatorFlow": false, 1304 | "userSetupAllowed": false 1305 | }, 1306 | { 1307 | "authenticator": "client-jwt", 1308 | "authenticatorFlow": false, 1309 | "requirement": "ALTERNATIVE", 1310 | "priority": 20, 1311 | "autheticatorFlow": false, 1312 | "userSetupAllowed": false 1313 | }, 1314 | { 1315 | "authenticator": "client-secret-jwt", 1316 | "authenticatorFlow": false, 1317 | "requirement": "ALTERNATIVE", 1318 | "priority": 30, 1319 | "autheticatorFlow": false, 1320 | "userSetupAllowed": false 1321 | }, 1322 | { 1323 | "authenticator": "client-x509", 1324 | "authenticatorFlow": false, 1325 | "requirement": "ALTERNATIVE", 1326 | "priority": 40, 1327 | "autheticatorFlow": false, 1328 | "userSetupAllowed": false 1329 | } 1330 | ] 1331 | }, 1332 | { 1333 | "id": "eeab3769-196e-456c-8aad-2a369b18cbd8", 1334 | "alias": "direct grant", 1335 | "description": "OpenID Connect Resource Owner Grant", 1336 | "providerId": "basic-flow", 1337 | "topLevel": true, 1338 | "builtIn": true, 1339 | "authenticationExecutions": [ 1340 | { 1341 | "authenticator": "direct-grant-validate-username", 1342 | "authenticatorFlow": false, 1343 | "requirement": "REQUIRED", 1344 | "priority": 10, 1345 | "autheticatorFlow": false, 1346 | "userSetupAllowed": false 1347 | }, 1348 | { 1349 | "authenticator": "direct-grant-validate-password", 1350 | "authenticatorFlow": false, 1351 | "requirement": "REQUIRED", 1352 | "priority": 20, 1353 | "autheticatorFlow": false, 1354 | "userSetupAllowed": false 1355 | }, 1356 | { 1357 | "authenticatorFlow": true, 1358 | "requirement": "CONDITIONAL", 1359 | "priority": 30, 1360 | "autheticatorFlow": true, 1361 | "flowAlias": "Direct Grant - Conditional OTP", 1362 | "userSetupAllowed": false 1363 | } 1364 | ] 1365 | }, 1366 | { 1367 | "id": "95392b0a-9920-49e5-84e9-51f96f9cb3e8", 1368 | "alias": "docker auth", 1369 | "description": "Used by Docker clients to authenticate against the IDP", 1370 | "providerId": "basic-flow", 1371 | "topLevel": true, 1372 | "builtIn": true, 1373 | "authenticationExecutions": [ 1374 | { 1375 | "authenticator": "docker-http-basic-authenticator", 1376 | "authenticatorFlow": false, 1377 | "requirement": "REQUIRED", 1378 | "priority": 10, 1379 | "autheticatorFlow": false, 1380 | "userSetupAllowed": false 1381 | } 1382 | ] 1383 | }, 1384 | { 1385 | "id": "d8c19600-d98a-47ff-9fca-5f3d8051269a", 1386 | "alias": "first broker login", 1387 | "description": "Actions taken after first broker login with identity provider account, which is not yet linked to any Keycloak account", 1388 | "providerId": "basic-flow", 1389 | "topLevel": true, 1390 | "builtIn": true, 1391 | "authenticationExecutions": [ 1392 | { 1393 | "authenticatorConfig": "review profile config", 1394 | "authenticator": "idp-review-profile", 1395 | "authenticatorFlow": false, 1396 | "requirement": "REQUIRED", 1397 | "priority": 10, 1398 | "autheticatorFlow": false, 1399 | "userSetupAllowed": false 1400 | }, 1401 | { 1402 | "authenticatorFlow": true, 1403 | "requirement": "REQUIRED", 1404 | "priority": 20, 1405 | "autheticatorFlow": true, 1406 | "flowAlias": "User creation or linking", 1407 | "userSetupAllowed": false 1408 | } 1409 | ] 1410 | }, 1411 | { 1412 | "id": "10f2dce6-0cb3-49e0-8c01-b8d7c5c52763", 1413 | "alias": "forms", 1414 | "description": "Username, password, otp and other auth forms.", 1415 | "providerId": "basic-flow", 1416 | "topLevel": false, 1417 | "builtIn": true, 1418 | "authenticationExecutions": [ 1419 | { 1420 | "authenticator": "auth-username-password-form", 1421 | "authenticatorFlow": false, 1422 | "requirement": "REQUIRED", 1423 | "priority": 10, 1424 | "autheticatorFlow": false, 1425 | "userSetupAllowed": false 1426 | }, 1427 | { 1428 | "authenticatorFlow": true, 1429 | "requirement": "CONDITIONAL", 1430 | "priority": 20, 1431 | "autheticatorFlow": true, 1432 | "flowAlias": "Browser - Conditional OTP", 1433 | "userSetupAllowed": false 1434 | } 1435 | ] 1436 | }, 1437 | { 1438 | "id": "7b08d38c-bee8-4a95-8d68-d003904010d7", 1439 | "alias": "http challenge", 1440 | "description": "An authentication flow based on challenge-response HTTP Authentication Schemes", 1441 | "providerId": "basic-flow", 1442 | "topLevel": true, 1443 | "builtIn": true, 1444 | "authenticationExecutions": [ 1445 | { 1446 | "authenticator": "no-cookie-redirect", 1447 | "authenticatorFlow": false, 1448 | "requirement": "REQUIRED", 1449 | "priority": 10, 1450 | "autheticatorFlow": false, 1451 | "userSetupAllowed": false 1452 | }, 1453 | { 1454 | "authenticatorFlow": true, 1455 | "requirement": "REQUIRED", 1456 | "priority": 20, 1457 | "autheticatorFlow": true, 1458 | "flowAlias": "Authentication Options", 1459 | "userSetupAllowed": false 1460 | } 1461 | ] 1462 | }, 1463 | { 1464 | "id": "b1321e6b-eb39-4158-b6e2-02d4eb3e8e8d", 1465 | "alias": "registration", 1466 | "description": "registration flow", 1467 | "providerId": "basic-flow", 1468 | "topLevel": true, 1469 | "builtIn": true, 1470 | "authenticationExecutions": [ 1471 | { 1472 | "authenticator": "registration-page-form", 1473 | "authenticatorFlow": true, 1474 | "requirement": "REQUIRED", 1475 | "priority": 10, 1476 | "autheticatorFlow": true, 1477 | "flowAlias": "registration form", 1478 | "userSetupAllowed": false 1479 | } 1480 | ] 1481 | }, 1482 | { 1483 | "id": "b41573dc-6002-41cb-a02d-976c2d80c321", 1484 | "alias": "registration form", 1485 | "description": "registration form", 1486 | "providerId": "form-flow", 1487 | "topLevel": false, 1488 | "builtIn": true, 1489 | "authenticationExecutions": [ 1490 | { 1491 | "authenticator": "registration-user-creation", 1492 | "authenticatorFlow": false, 1493 | "requirement": "REQUIRED", 1494 | "priority": 20, 1495 | "autheticatorFlow": false, 1496 | "userSetupAllowed": false 1497 | }, 1498 | { 1499 | "authenticator": "registration-profile-action", 1500 | "authenticatorFlow": false, 1501 | "requirement": "REQUIRED", 1502 | "priority": 40, 1503 | "autheticatorFlow": false, 1504 | "userSetupAllowed": false 1505 | }, 1506 | { 1507 | "authenticator": "registration-password-action", 1508 | "authenticatorFlow": false, 1509 | "requirement": "REQUIRED", 1510 | "priority": 50, 1511 | "autheticatorFlow": false, 1512 | "userSetupAllowed": false 1513 | }, 1514 | { 1515 | "authenticator": "registration-recaptcha-action", 1516 | "authenticatorFlow": false, 1517 | "requirement": "DISABLED", 1518 | "priority": 60, 1519 | "autheticatorFlow": false, 1520 | "userSetupAllowed": false 1521 | } 1522 | ] 1523 | }, 1524 | { 1525 | "id": "532a0d17-0d11-4fc4-8072-62261b7f6d46", 1526 | "alias": "reset credentials", 1527 | "description": "Reset credentials for a user if they forgot their password or something", 1528 | "providerId": "basic-flow", 1529 | "topLevel": true, 1530 | "builtIn": true, 1531 | "authenticationExecutions": [ 1532 | { 1533 | "authenticator": "reset-credentials-choose-user", 1534 | "authenticatorFlow": false, 1535 | "requirement": "REQUIRED", 1536 | "priority": 10, 1537 | "autheticatorFlow": false, 1538 | "userSetupAllowed": false 1539 | }, 1540 | { 1541 | "authenticator": "reset-credential-email", 1542 | "authenticatorFlow": false, 1543 | "requirement": "REQUIRED", 1544 | "priority": 20, 1545 | "autheticatorFlow": false, 1546 | "userSetupAllowed": false 1547 | }, 1548 | { 1549 | "authenticator": "reset-password", 1550 | "authenticatorFlow": false, 1551 | "requirement": "REQUIRED", 1552 | "priority": 30, 1553 | "autheticatorFlow": false, 1554 | "userSetupAllowed": false 1555 | }, 1556 | { 1557 | "authenticatorFlow": true, 1558 | "requirement": "CONDITIONAL", 1559 | "priority": 40, 1560 | "autheticatorFlow": true, 1561 | "flowAlias": "Reset - Conditional OTP", 1562 | "userSetupAllowed": false 1563 | } 1564 | ] 1565 | }, 1566 | { 1567 | "id": "a8cf948b-2380-49f6-a247-19deb5989fce", 1568 | "alias": "saml ecp", 1569 | "description": "SAML ECP Profile Authentication Flow", 1570 | "providerId": "basic-flow", 1571 | "topLevel": true, 1572 | "builtIn": true, 1573 | "authenticationExecutions": [ 1574 | { 1575 | "authenticator": "http-basic-authenticator", 1576 | "authenticatorFlow": false, 1577 | "requirement": "REQUIRED", 1578 | "priority": 10, 1579 | "autheticatorFlow": false, 1580 | "userSetupAllowed": false 1581 | } 1582 | ] 1583 | } 1584 | ], 1585 | "authenticatorConfig": [ 1586 | { 1587 | "id": "0216f4e4-778d-491e-95a6-41da615089c6", 1588 | "alias": "2FA - Browser Browser - Conditional OTP - Credential configured", 1589 | "config": { 1590 | "auth": "webauthn##otp", 1591 | "negate": "false" 1592 | } 1593 | }, 1594 | { 1595 | "id": "92d955d7-1b42-41d9-965e-e55ce437f6cb", 1596 | "alias": "2FA - Browser Browser - Conditional OTP - Device NOT trusted", 1597 | "config": { 1598 | "negate": "true" 1599 | } 1600 | }, 1601 | { 1602 | "id": "4c20aaa5-8686-40d3-a76a-dcb089faec44", 1603 | "alias": "2FA - Browser Browser - Conditional OTP - Register Trusted Device", 1604 | "config": { 1605 | "duration": "P90d" 1606 | } 1607 | }, 1608 | { 1609 | "id": "0c35f9ff-0c5c-4a00-8fd3-4d0ac16da822", 1610 | "alias": "2FA - Direct Grant Direct Grant - Conditional OTP - Credential configured", 1611 | "config": { 1612 | "auth": "webauthn##otp", 1613 | "negate": "false" 1614 | } 1615 | }, 1616 | { 1617 | "id": "5f57f369-53bf-4e24-bc8c-4d6c32fad99d", 1618 | "alias": "create unique user config", 1619 | "config": { 1620 | "require.password.update.after.registration": "false" 1621 | } 1622 | }, 1623 | { 1624 | "id": "51c9bc40-3271-41d4-9592-5098078248c8", 1625 | "alias": "review profile config", 1626 | "config": { 1627 | "update.profile.on.first.login": "missing" 1628 | } 1629 | } 1630 | ], 1631 | "requiredActions": [ 1632 | { 1633 | "alias": "CONFIGURE_TOTP", 1634 | "name": "Configure OTP", 1635 | "providerId": "CONFIGURE_TOTP", 1636 | "enabled": true, 1637 | "defaultAction": false, 1638 | "priority": 10, 1639 | "config": {} 1640 | }, 1641 | { 1642 | "alias": "terms_and_conditions", 1643 | "name": "Terms and Conditions", 1644 | "providerId": "terms_and_conditions", 1645 | "enabled": false, 1646 | "defaultAction": false, 1647 | "priority": 20, 1648 | "config": {} 1649 | }, 1650 | { 1651 | "alias": "UPDATE_PASSWORD", 1652 | "name": "Update Password", 1653 | "providerId": "UPDATE_PASSWORD", 1654 | "enabled": true, 1655 | "defaultAction": false, 1656 | "priority": 30, 1657 | "config": {} 1658 | }, 1659 | { 1660 | "alias": "UPDATE_PROFILE", 1661 | "name": "Update Profile", 1662 | "providerId": "UPDATE_PROFILE", 1663 | "enabled": true, 1664 | "defaultAction": false, 1665 | "priority": 40, 1666 | "config": {} 1667 | }, 1668 | { 1669 | "alias": "VERIFY_EMAIL", 1670 | "name": "Verify Email", 1671 | "providerId": "VERIFY_EMAIL", 1672 | "enabled": true, 1673 | "defaultAction": false, 1674 | "priority": 50, 1675 | "config": {} 1676 | }, 1677 | { 1678 | "alias": "delete_account", 1679 | "name": "Delete Account", 1680 | "providerId": "delete_account", 1681 | "enabled": false, 1682 | "defaultAction": false, 1683 | "priority": 60, 1684 | "config": {} 1685 | }, 1686 | { 1687 | "alias": "webauthn-register", 1688 | "name": "Webauthn Register", 1689 | "providerId": "webauthn-register", 1690 | "enabled": true, 1691 | "defaultAction": false, 1692 | "priority": 70, 1693 | "config": {} 1694 | }, 1695 | { 1696 | "alias": "webauthn-register-passwordless", 1697 | "name": "Webauthn Register Passwordless", 1698 | "providerId": "webauthn-register-passwordless", 1699 | "enabled": true, 1700 | "defaultAction": false, 1701 | "priority": 80, 1702 | "config": {} 1703 | }, 1704 | { 1705 | "alias": "update_user_locale", 1706 | "name": "Update User Locale", 1707 | "providerId": "update_user_locale", 1708 | "enabled": true, 1709 | "defaultAction": false, 1710 | "priority": 1000, 1711 | "config": {} 1712 | } 1713 | ], 1714 | "browserFlow": "2FA - Browser", 1715 | "registrationFlow": "registration", 1716 | "directGrantFlow": "2FA - direct grant", 1717 | "resetCredentialsFlow": "reset credentials", 1718 | "clientAuthenticationFlow": "clients", 1719 | "dockerAuthenticationFlow": "docker auth", 1720 | "attributes": { 1721 | "cibaBackchannelTokenDeliveryMode": "poll", 1722 | "cibaExpiresIn": "120", 1723 | "cibaAuthRequestedUserHint": "login_hint", 1724 | "oauth2DeviceCodeLifespan": "600", 1725 | "oauth2DevicePollingInterval": "5", 1726 | "clientOfflineSessionMaxLifespan": "0", 1727 | "clientSessionIdleTimeout": "0", 1728 | "parRequestUriLifespan": "60", 1729 | "clientSessionMaxLifespan": "0", 1730 | "clientOfflineSessionIdleTimeout": "0", 1731 | "cibaInterval": "5", 1732 | "realmReusableOtpCode": "false" 1733 | }, 1734 | "keycloakVersion": "20.0.3", 1735 | "userManagedAccessAllowed": false, 1736 | "clientProfiles": { 1737 | "profiles": [] 1738 | }, 1739 | "clientPolicies": { 1740 | "policies": [] 1741 | } 1742 | } 1743 | -------------------------------------------------------------------------------- /run-dev.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -xeuo pipefail 3 | mvn package -DskipTests 4 | docker-compose up --build -d 5 | docker-compose logs --no-log-prefix -f keycloak 6 | -------------------------------------------------------------------------------- /spi/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | com.github.wouterh-dev 8 | keycloak-spi-trusted-device-parent 9 | ${revision} 10 | ../pom.xml 11 | 12 | 13 | keycloak-spi-trusted-device 14 | spi 15 | jar 16 | 17 | 18 | 19 | org.keycloak 20 | keycloak-core 21 | provided 22 | 23 | 24 | org.keycloak 25 | keycloak-services 26 | provided 27 | 28 | 29 | org.keycloak 30 | keycloak-model-jpa 31 | provided 32 | 33 | 34 | org.keycloak 35 | keycloak-server-spi 36 | provided 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-shade-plugin 45 | 3.4.1 46 | 47 | 48 | 49 | 50 | package 51 | 52 | shade 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/authenticator/CredentialConfiguredCondition.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.authenticator; 2 | 3 | import java.util.Arrays; 4 | import lombok.extern.jbosslog.JBossLog; 5 | import org.keycloak.authentication.AuthenticationFlowContext; 6 | import org.keycloak.authentication.authenticators.conditional.ConditionalAuthenticator; 7 | import org.keycloak.models.AuthenticatorConfigModel; 8 | import org.keycloak.models.Constants; 9 | import org.keycloak.models.KeycloakSession; 10 | import org.keycloak.models.RealmModel; 11 | import org.keycloak.models.UserModel; 12 | 13 | @JBossLog 14 | public class CredentialConfiguredCondition implements ConditionalAuthenticator { 15 | 16 | public static final CredentialConfiguredCondition SINGLETON = new CredentialConfiguredCondition(); 17 | 18 | @Override 19 | public boolean matchCondition(AuthenticationFlowContext context) { 20 | AuthenticatorConfigModel authConfig = context.getAuthenticatorConfig(); 21 | 22 | if (authConfig != null && authConfig.getConfig() != null) { 23 | boolean negateOutput = Boolean.parseBoolean( 24 | authConfig.getConfig().get(CredentialConfiguredConditionFactory.CONF_NEGATE)); 25 | boolean hasAuthenticator = false; 26 | 27 | String authenticatorNamesStr = authConfig.getConfig() 28 | .get(CredentialConfiguredConditionFactory.CONF_AUTH); 29 | if (authenticatorNamesStr != null) { 30 | String[] authenticatorNames = Constants.CFG_DELIMITER_PATTERN.split( 31 | authenticatorNamesStr); 32 | hasAuthenticator = Arrays.stream(authenticatorNames) 33 | .anyMatch(authenticator -> context.getUser().credentialManager() 34 | .isConfiguredFor(authenticator)); 35 | } 36 | 37 | return hasAuthenticator != negateOutput; 38 | } 39 | 40 | return false; 41 | } 42 | 43 | @Override 44 | public void action(AuthenticationFlowContext context) { 45 | // Not used 46 | } 47 | 48 | @Override 49 | public boolean requiresUser() { 50 | return true; 51 | } 52 | 53 | @Override 54 | public void setRequiredActions(KeycloakSession session, RealmModel realm, UserModel user) { 55 | // Not used 56 | } 57 | 58 | @Override 59 | public void close() { 60 | // Does nothing 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/authenticator/CredentialConfiguredConditionFactory.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.authenticator; 2 | 3 | import com.google.auto.service.AutoService; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import org.keycloak.Config; 7 | import org.keycloak.authentication.AuthenticatorFactory; 8 | import org.keycloak.authentication.authenticators.conditional.ConditionalAuthenticator; 9 | import org.keycloak.authentication.authenticators.conditional.ConditionalAuthenticatorFactory; 10 | import org.keycloak.models.AuthenticationExecutionModel.Requirement; 11 | import org.keycloak.models.KeycloakSessionFactory; 12 | import org.keycloak.provider.ProviderConfigProperty; 13 | 14 | @AutoService(AuthenticatorFactory.class) 15 | public class CredentialConfiguredConditionFactory implements 16 | ConditionalAuthenticatorFactory { 17 | 18 | public static final String CONF_NEGATE = "negate"; 19 | public static final String CONF_AUTH = "auth"; 20 | public static final String PROVIDER_ID = "configured-credential-condition"; 21 | 22 | @Override 23 | public String getDisplayType() { 24 | return "Condition - Credential Configured"; 25 | } 26 | 27 | @Override 28 | public ConditionalAuthenticator getSingleton() { 29 | return CredentialConfiguredCondition.SINGLETON; 30 | } 31 | 32 | @Override 33 | public boolean isConfigurable() { 34 | return true; 35 | } 36 | 37 | private static final Requirement[] REQUIREMENT_CHOICES = { 38 | Requirement.REQUIRED, 39 | Requirement.DISABLED 40 | }; 41 | 42 | @Override 43 | public Requirement[] getRequirementChoices() { 44 | return REQUIREMENT_CHOICES; 45 | } 46 | 47 | @Override 48 | public boolean isUserSetupAllowed() { 49 | return true; 50 | } 51 | 52 | @Override 53 | public String getHelpText() { 54 | return "Flow is only executed if device is trusted."; 55 | } 56 | 57 | 58 | @Override 59 | public List getConfigProperties() { 60 | ProviderConfigProperty authTypes = new ProviderConfigProperty(); 61 | authTypes.setType(ProviderConfigProperty.MULTIVALUED_STRING_TYPE); 62 | authTypes.setName(CONF_AUTH); 63 | authTypes.setLabel("Authenticator types"); 64 | authTypes.setHelpText( 65 | "Condition matches if one of the user has one of the authenticator types configured"); 66 | authTypes.setDefaultValue("otp"); 67 | 68 | ProviderConfigProperty negateOutput = new ProviderConfigProperty(); 69 | negateOutput.setType(ProviderConfigProperty.BOOLEAN_TYPE); 70 | negateOutput.setName(CONF_NEGATE); 71 | negateOutput.setLabel("Negate output"); 72 | negateOutput.setDefaultValue(Boolean.toString(false)); 73 | negateOutput.setHelpText( 74 | "Apply a NOT to the check result. When this is true, then the condition will evaluate to true just if user does NOT have any of the authenticators configured. When this is false, the condition will evaluate to true if user has any of the configured authenticators"); 75 | 76 | return Arrays.asList(authTypes, negateOutput); 77 | } 78 | 79 | @Override 80 | public void init(Config.Scope config) { 81 | 82 | } 83 | 84 | @Override 85 | public void postInit(KeycloakSessionFactory factory) { 86 | } 87 | 88 | @Override 89 | public void close() { 90 | 91 | } 92 | 93 | @Override 94 | public String getId() { 95 | return PROVIDER_ID; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/authenticator/RegisterTrustedDeviceAuthenticator.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.authenticator; 2 | 3 | import static nl.wouterh.keycloak.trusteddevice.authenticator.RegisterTrustedDeviceAuthenticatorFactory.CONF_DURATION; 4 | 5 | import com.google.common.base.Strings; 6 | import java.security.SecureRandom; 7 | import java.time.Duration; 8 | import java.time.Instant; 9 | import java.time.ZoneId; 10 | import java.time.format.DateTimeFormatter; 11 | import java.util.Map; 12 | import jakarta.ws.rs.core.MultivaluedMap; 13 | import jakarta.ws.rs.core.Response; 14 | import nl.wouterh.keycloak.trusteddevice.credential.TrustedDeviceCredentialModel; 15 | import nl.wouterh.keycloak.trusteddevice.credential.TrustedDeviceCredentialProvider; 16 | import nl.wouterh.keycloak.trusteddevice.credential.TrustedDeviceCredentialProviderFactory; 17 | import nl.wouterh.keycloak.trusteddevice.util.TrustedDeviceToken; 18 | import nl.wouterh.keycloak.trusteddevice.util.UserAgentParser; 19 | import org.apache.commons.codec.binary.Hex; 20 | import org.keycloak.authentication.AuthenticationFlowContext; 21 | import org.keycloak.authentication.Authenticator; 22 | import org.keycloak.common.util.Time; 23 | import org.keycloak.credential.CredentialModel; 24 | import org.keycloak.credential.CredentialProvider; 25 | import org.keycloak.models.AuthenticatorConfigModel; 26 | import org.keycloak.models.KeycloakSession; 27 | import org.keycloak.models.RealmModel; 28 | import org.keycloak.models.UserModel; 29 | 30 | public class RegisterTrustedDeviceAuthenticator implements Authenticator { 31 | 32 | private static final SecureRandom secureRandom = new SecureRandom(); 33 | private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") 34 | .withZone(ZoneId.of("UTC")); 35 | 36 | private final KeycloakSession session; 37 | 38 | public RegisterTrustedDeviceAuthenticator(KeycloakSession session) { 39 | this.session = session; 40 | } 41 | 42 | @Override 43 | public void authenticate(AuthenticationFlowContext context) { 44 | UserModel user = context.getUser(); 45 | RealmModel realm = context.getRealm(); 46 | 47 | TrustedDeviceCredentialModel credential = TrustedDeviceToken.getCredentialFromCookie( 48 | context.getSession(), realm, user); 49 | 50 | if (credential != null) { 51 | context.success(); 52 | } else { 53 | Response form = context.form() 54 | .setAttribute("trustedDeviceName", UserAgentParser.getDeviceName(session)) 55 | .createForm("trusted-device-register.ftl"); 56 | context.challenge(form); 57 | } 58 | } 59 | 60 | @Override 61 | public void action(AuthenticationFlowContext context) { 62 | UserModel user = context.getUser(); 63 | RealmModel realm = context.getRealm(); 64 | 65 | TrustedDeviceCredentialModel existingCredential = TrustedDeviceToken.getCredentialFromCookie( 66 | session, context.getRealm(), context.getUser()); 67 | if (existingCredential != null) { 68 | return; 69 | } 70 | 71 | Duration duration = null; 72 | 73 | AuthenticatorConfigModel authenticatorConfig = context.getAuthenticatorConfig(); 74 | if (authenticatorConfig != null) { 75 | Map config = authenticatorConfig.getConfig(); 76 | if (config != null && !Strings.isNullOrEmpty(config.get(CONF_DURATION))) { 77 | duration = Duration.parse(config.get(CONF_DURATION)); 78 | } 79 | } 80 | 81 | MultivaluedMap formParameters = context.getHttpRequest() 82 | .getDecodedFormParameters(); 83 | 84 | boolean trustedDevice = "yes".equals(formParameters.getFirst("trusted-device")); 85 | String deviceName = formParameters.getFirst("trusted-device-name"); 86 | 87 | if (trustedDevice && !Strings.isNullOrEmpty(deviceName)) { 88 | TrustedDeviceCredentialProvider trustedDeviceCredentialProvider = (TrustedDeviceCredentialProvider) session.getProvider( 89 | CredentialProvider.class, TrustedDeviceCredentialProviderFactory.PROVIDER_ID); 90 | 91 | // Generate a random 32 byte deviceId 92 | byte[] bytes = new byte[32]; 93 | secureRandom.nextBytes(bytes); 94 | String deviceId = Hex.encodeHexString(bytes); 95 | 96 | // Expire the token in 1 year 97 | Long exp = null; 98 | String credentialName = deviceName; 99 | if (duration != null) { 100 | exp = Time.currentTime() + duration.getSeconds(); 101 | 102 | credentialName = String.format("%s (Expires: %s)", deviceName, 103 | formatter.format(Instant.ofEpochSecond(exp))); 104 | } 105 | 106 | TrustedDeviceCredentialModel trustedDeviceCredentialModel = TrustedDeviceCredentialModel.create( 107 | credentialName, deviceId, exp); 108 | 109 | trustedDeviceCredentialProvider.removeExpiredCredentials(realm, user); 110 | 111 | // Add the new credential 112 | CredentialModel credential = trustedDeviceCredentialProvider.createCredential(realm, user, 113 | trustedDeviceCredentialModel); 114 | 115 | int cookieExpirationTime = duration != null ? (int) duration.getSeconds() : Integer.MAX_VALUE; 116 | 117 | TrustedDeviceToken token = new TrustedDeviceToken(credential.getId(), deviceId, exp); 118 | TrustedDeviceToken.addCookie(session, realm, token, cookieExpirationTime); 119 | } 120 | 121 | context.success(); 122 | } 123 | 124 | 125 | @Override 126 | public boolean requiresUser() { 127 | return true; 128 | } 129 | 130 | @Override 131 | public boolean configuredFor(KeycloakSession session, RealmModel realm, UserModel user) { 132 | return true; 133 | } 134 | 135 | @Override 136 | public void setRequiredActions(KeycloakSession session, RealmModel realm, UserModel user) { 137 | } 138 | 139 | @Override 140 | public void close() { 141 | 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/authenticator/RegisterTrustedDeviceAuthenticatorFactory.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.authenticator; 2 | 3 | import com.google.auto.service.AutoService; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import nl.wouterh.keycloak.trusteddevice.credential.TrustedDeviceCredentialModel; 7 | import org.keycloak.Config; 8 | import org.keycloak.authentication.Authenticator; 9 | import org.keycloak.authentication.AuthenticatorFactory; 10 | import org.keycloak.models.AuthenticationExecutionModel; 11 | import org.keycloak.models.KeycloakSession; 12 | import org.keycloak.models.KeycloakSessionFactory; 13 | import org.keycloak.provider.ProviderConfigProperty; 14 | 15 | @AutoService(AuthenticatorFactory.class) 16 | public class RegisterTrustedDeviceAuthenticatorFactory implements AuthenticatorFactory { 17 | 18 | public static final String CONF_DURATION = "duration"; 19 | 20 | public static final String PROVIDER_ID = "trusted-device-authenticator"; 21 | 22 | @Override 23 | public String getDisplayType() { 24 | return "Register Trusted Device"; 25 | } 26 | 27 | @Override 28 | public String getReferenceCategory() { 29 | return TrustedDeviceCredentialModel.TYPE_TWOFACTOR; 30 | } 31 | 32 | @Override 33 | public boolean isConfigurable() { 34 | return true; 35 | } 36 | 37 | @Override 38 | public AuthenticationExecutionModel.Requirement[] getRequirementChoices() { 39 | return REQUIREMENT_CHOICES; 40 | } 41 | 42 | @Override 43 | public boolean isUserSetupAllowed() { 44 | return true; 45 | } 46 | 47 | @Override 48 | public String getHelpText() { 49 | return "Prompts the user if they want to trust their device. Use 'Condition - Credential Configured' to check if the device is trusted."; 50 | } 51 | 52 | 53 | @Override 54 | public List getConfigProperties() { 55 | ProviderConfigProperty duration = new ProviderConfigProperty(); 56 | duration.setType(ProviderConfigProperty.STRING_TYPE); 57 | duration.setName(CONF_DURATION); 58 | duration.setLabel("Trust duration"); 59 | duration.setDefaultValue(""); 60 | duration.setHelpText( 61 | "Duration the device will be trusted. Input format is a Java Duration, for example P365d or PT24h. Empty value means forever."); 62 | 63 | return Arrays.asList(duration); 64 | } 65 | 66 | @Override 67 | public Authenticator create(KeycloakSession session) { 68 | return new RegisterTrustedDeviceAuthenticator(session); 69 | } 70 | 71 | @Override 72 | public void init(Config.Scope config) { 73 | 74 | } 75 | 76 | @Override 77 | public void postInit(KeycloakSessionFactory factory) { 78 | 79 | } 80 | 81 | @Override 82 | public void close() { 83 | 84 | } 85 | 86 | @Override 87 | public String getId() { 88 | return PROVIDER_ID; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/authenticator/TrustedDeviceCondition.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.authenticator; 2 | 3 | import lombok.extern.jbosslog.JBossLog; 4 | import nl.wouterh.keycloak.trusteddevice.credential.TrustedDeviceCredentialModel; 5 | import nl.wouterh.keycloak.trusteddevice.util.TrustedDeviceToken; 6 | import org.keycloak.authentication.AuthenticationFlowContext; 7 | import org.keycloak.authentication.authenticators.conditional.ConditionalAuthenticator; 8 | import org.keycloak.models.AuthenticatorConfigModel; 9 | import org.keycloak.models.KeycloakSession; 10 | import org.keycloak.models.RealmModel; 11 | import org.keycloak.models.UserModel; 12 | 13 | @JBossLog 14 | public class TrustedDeviceCondition implements ConditionalAuthenticator { 15 | 16 | public static final TrustedDeviceCondition SINGLETON = new TrustedDeviceCondition(); 17 | 18 | @Override 19 | public boolean matchCondition(AuthenticationFlowContext context) { 20 | AuthenticatorConfigModel authConfig = context.getAuthenticatorConfig(); 21 | 22 | TrustedDeviceCredentialModel credential = TrustedDeviceToken.getCredentialFromCookie( 23 | context.getSession(), context.getRealm(), context.getUser()); 24 | 25 | boolean trustedDevice = credential != null; 26 | 27 | if (authConfig != null && authConfig.getConfig() != null) { 28 | boolean negateOutput = Boolean.parseBoolean( 29 | authConfig.getConfig().get(TrustedDeviceConditionFactory.CONF_NEGATE)); 30 | 31 | return negateOutput != trustedDevice; 32 | } 33 | 34 | return false; 35 | } 36 | 37 | @Override 38 | public void action(AuthenticationFlowContext context) { 39 | // Not used 40 | } 41 | 42 | @Override 43 | public boolean requiresUser() { 44 | return true; 45 | } 46 | 47 | @Override 48 | public void setRequiredActions(KeycloakSession session, RealmModel realm, UserModel user) { 49 | // Not used 50 | } 51 | 52 | @Override 53 | public void close() { 54 | // Does nothing 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/authenticator/TrustedDeviceConditionFactory.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.authenticator; 2 | 3 | import com.google.auto.service.AutoService; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import nl.wouterh.keycloak.trusteddevice.credential.TrustedDeviceCredentialModel; 7 | import org.keycloak.Config; 8 | import org.keycloak.authentication.AuthenticatorFactory; 9 | import org.keycloak.authentication.authenticators.conditional.ConditionalAuthenticator; 10 | import org.keycloak.authentication.authenticators.conditional.ConditionalAuthenticatorFactory; 11 | import org.keycloak.models.AuthenticationExecutionModel.Requirement; 12 | import org.keycloak.models.KeycloakSessionFactory; 13 | import org.keycloak.provider.ProviderConfigProperty; 14 | 15 | @AutoService(AuthenticatorFactory.class) 16 | public class TrustedDeviceConditionFactory implements 17 | ConditionalAuthenticatorFactory { 18 | 19 | public static final String CONF_NEGATE = "negate"; 20 | public static final String PROVIDER_ID = "trusted-device-condition"; 21 | 22 | @Override 23 | public String getDisplayType() { 24 | return "Condition - Device Trusted"; 25 | } 26 | 27 | @Override 28 | public String getReferenceCategory() { 29 | return TrustedDeviceCredentialModel.TYPE_TWOFACTOR; 30 | } 31 | 32 | @Override 33 | public ConditionalAuthenticator getSingleton() { 34 | return TrustedDeviceCondition.SINGLETON; 35 | } 36 | 37 | @Override 38 | public boolean isConfigurable() { 39 | return true; 40 | } 41 | 42 | private static final Requirement[] REQUIREMENT_CHOICES = { 43 | Requirement.REQUIRED, 44 | Requirement.DISABLED 45 | }; 46 | 47 | @Override 48 | public Requirement[] getRequirementChoices() { 49 | return REQUIREMENT_CHOICES; 50 | } 51 | 52 | @Override 53 | public boolean isUserSetupAllowed() { 54 | return true; 55 | } 56 | 57 | @Override 58 | public String getHelpText() { 59 | return "Flow is only executed if device is trusted."; 60 | } 61 | 62 | 63 | @Override 64 | public List getConfigProperties() { 65 | ProviderConfigProperty negateOutput = new ProviderConfigProperty(); 66 | negateOutput.setType(ProviderConfigProperty.BOOLEAN_TYPE); 67 | negateOutput.setName(CONF_NEGATE); 68 | negateOutput.setLabel("Negate output"); 69 | negateOutput.setDefaultValue(Boolean.toString(true)); 70 | negateOutput.setHelpText( 71 | "Apply a NOT to the check result. When this is true, then the condition will evaluate to true just if user does NOT have a trusted device. When this is false, the condition will evaluate to true just if user has a trusted device"); 72 | 73 | return Arrays.asList(negateOutput); 74 | } 75 | 76 | 77 | @Override 78 | public void init(Config.Scope config) { 79 | 80 | } 81 | 82 | @Override 83 | public void postInit(KeycloakSessionFactory factory) { 84 | 85 | } 86 | 87 | @Override 88 | public void close() { 89 | 90 | } 91 | 92 | @Override 93 | public String getId() { 94 | return PROVIDER_ID; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/credential/TrustedDeviceCredentialData.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.credential; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class TrustedDeviceCredentialData { 11 | 12 | private Long expireTime; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/credential/TrustedDeviceCredentialModel.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.credential; 2 | 3 | import java.io.IOException; 4 | import org.keycloak.common.util.Time; 5 | import org.keycloak.credential.CredentialModel; 6 | import org.keycloak.util.JsonSerialization; 7 | 8 | public class TrustedDeviceCredentialModel extends CredentialModel { 9 | 10 | public static final String TYPE_TWOFACTOR = "trusted-device"; 11 | 12 | private final TrustedDeviceCredentialData credentialData; 13 | private final TrustedDeviceSecretData secretData; 14 | 15 | private TrustedDeviceCredentialModel(TrustedDeviceCredentialData credentialData, 16 | TrustedDeviceSecretData secretData) { 17 | this.credentialData = credentialData; 18 | this.secretData = secretData; 19 | } 20 | 21 | public Long getExpireTime() { 22 | return credentialData.getExpireTime(); 23 | } 24 | 25 | public String getDeviceId() { 26 | return secretData.getDeviceId(); 27 | } 28 | 29 | public static TrustedDeviceCredentialModel create(String userLabel, String deviceId, 30 | Long expireTime) { 31 | TrustedDeviceCredentialData trustedDeviceCredentialData = new TrustedDeviceCredentialData( 32 | expireTime); 33 | TrustedDeviceSecretData trustedDeviceSecretData = new TrustedDeviceSecretData(deviceId); 34 | TrustedDeviceCredentialModel credentialModel = new TrustedDeviceCredentialModel( 35 | trustedDeviceCredentialData, trustedDeviceSecretData); 36 | 37 | credentialModel.setType(TYPE_TWOFACTOR); 38 | 39 | credentialModel.fillCredentialModelFields(); 40 | credentialModel.setUserLabel(userLabel); 41 | 42 | return credentialModel; 43 | } 44 | 45 | public static TrustedDeviceCredentialModel createFromCredentialModel( 46 | CredentialModel credentialModel) { 47 | try { 48 | TrustedDeviceCredentialData credentialData = JsonSerialization.readValue( 49 | credentialModel.getCredentialData(), TrustedDeviceCredentialData.class); 50 | TrustedDeviceSecretData secretData = JsonSerialization.readValue( 51 | credentialModel.getSecretData(), 52 | TrustedDeviceSecretData.class); 53 | 54 | TrustedDeviceCredentialModel trustedDeviceCredentialModel = new TrustedDeviceCredentialModel( 55 | credentialData, secretData); 56 | trustedDeviceCredentialModel.setUserLabel(credentialModel.getUserLabel()); 57 | trustedDeviceCredentialModel.setCreatedDate(credentialModel.getCreatedDate()); 58 | trustedDeviceCredentialModel.setType(credentialModel.getType()); 59 | trustedDeviceCredentialModel.setId(credentialModel.getId()); 60 | trustedDeviceCredentialModel.setSecretData(credentialModel.getSecretData()); 61 | trustedDeviceCredentialModel.setCredentialData(credentialModel.getCredentialData()); 62 | return trustedDeviceCredentialModel; 63 | } catch (IOException e) { 64 | throw new RuntimeException(e); 65 | } 66 | } 67 | 68 | private void fillCredentialModelFields() { 69 | try { 70 | setCredentialData(JsonSerialization.writeValueAsString(credentialData)); 71 | setSecretData(JsonSerialization.writeValueAsString(secretData)); 72 | setCreatedDate(Time.currentTimeMillis()); 73 | } catch (IOException e) { 74 | throw new RuntimeException(e); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/credential/TrustedDeviceCredentialProvider.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.credential; 2 | 3 | import java.util.Iterator; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | import org.keycloak.common.util.Time; 7 | import org.keycloak.credential.CredentialModel; 8 | import org.keycloak.credential.CredentialProvider; 9 | import org.keycloak.credential.CredentialTypeMetadata; 10 | import org.keycloak.credential.CredentialTypeMetadataContext; 11 | import org.keycloak.models.KeycloakSession; 12 | import org.keycloak.models.RealmModel; 13 | import org.keycloak.models.UserModel; 14 | 15 | public class TrustedDeviceCredentialProvider implements 16 | CredentialProvider { 17 | 18 | private KeycloakSession session; 19 | 20 | public TrustedDeviceCredentialProvider(KeycloakSession session) { 21 | this.session = session; 22 | } 23 | 24 | @Override 25 | public String getType() { 26 | return TrustedDeviceCredentialModel.TYPE_TWOFACTOR; 27 | } 28 | 29 | public List removeExpiredCredentials(RealmModel realm, 30 | UserModel user) { 31 | // Remove all other expired credentials 32 | List credentials = user.credentialManager() 33 | .getStoredCredentialsByTypeStream(TrustedDeviceCredentialModel.TYPE_TWOFACTOR) 34 | .map(TrustedDeviceCredentialModel::createFromCredentialModel) 35 | .collect(Collectors.toList()); 36 | 37 | long now = Time.currentTime(); 38 | Iterator it = credentials.iterator(); 39 | while (it.hasNext()) { 40 | TrustedDeviceCredentialModel credential = it.next(); 41 | if (credential.getExpireTime() != null && credential.getExpireTime() < now) { 42 | deleteCredential(realm, user, credential.getId()); 43 | it.remove(); 44 | } 45 | } 46 | 47 | return credentials; 48 | } 49 | 50 | public TrustedDeviceCredentialModel getActiveCredentialById(RealmModel realm, UserModel user, 51 | String id) { 52 | List credentials = removeExpiredCredentials(realm, user); 53 | for (TrustedDeviceCredentialModel credential : credentials) { 54 | if (id.equals(credential.getId())) { 55 | return credential; 56 | } 57 | } 58 | 59 | return null; 60 | } 61 | 62 | @Override 63 | public CredentialModel createCredential(RealmModel realm, UserModel user, 64 | TrustedDeviceCredentialModel credentialModel) { 65 | if (credentialModel.getCreatedDate() == null) { 66 | credentialModel.setCreatedDate(Time.currentTimeMillis()); 67 | } 68 | 69 | return user.credentialManager().createStoredCredential(credentialModel); 70 | } 71 | 72 | @Override 73 | public boolean deleteCredential(RealmModel realm, UserModel user, String credentialId) { 74 | return user.credentialManager().removeStoredCredentialById(credentialId); 75 | } 76 | 77 | @Override 78 | public TrustedDeviceCredentialModel getCredentialFromModel(CredentialModel model) { 79 | return TrustedDeviceCredentialModel.createFromCredentialModel(model); 80 | } 81 | 82 | @Override 83 | public CredentialTypeMetadata getCredentialTypeMetadata( 84 | CredentialTypeMetadataContext metadataContext) { 85 | return CredentialTypeMetadata.builder() 86 | .type(getType()) 87 | .category(CredentialTypeMetadata.Category.TWO_FACTOR) 88 | .displayName("trusted-device-display-name") 89 | .helpText("trusted-device-help-text") 90 | .iconCssClass("kcAuthenticatorWebAuthnClass") 91 | .removeable(true) 92 | .build(session); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/credential/TrustedDeviceCredentialProviderFactory.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.credential; 2 | 3 | import com.google.auto.service.AutoService; 4 | import org.keycloak.credential.CredentialProvider; 5 | import org.keycloak.credential.CredentialProviderFactory; 6 | import org.keycloak.models.KeycloakSession; 7 | 8 | @AutoService(CredentialProviderFactory.class) 9 | public class TrustedDeviceCredentialProviderFactory implements 10 | CredentialProviderFactory { 11 | 12 | public static final String PROVIDER_ID = "trusted-device"; 13 | 14 | @Override 15 | public CredentialProvider create(KeycloakSession session) { 16 | return new TrustedDeviceCredentialProvider(session); 17 | } 18 | 19 | @Override 20 | public String getId() { 21 | return PROVIDER_ID; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/credential/TrustedDeviceSecretData.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.credential; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class TrustedDeviceSecretData { 11 | 12 | private String deviceId; 13 | } 14 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/util/TrustedDeviceToken.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.util; 2 | 3 | import jakarta.ws.rs.core.NewCookie; 4 | import jakarta.ws.rs.core.UriBuilder; 5 | import jakarta.ws.rs.core.NewCookie.SameSite; 6 | import jakarta.ws.rs.core.Cookie; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.Setter; 10 | import nl.wouterh.keycloak.trusteddevice.credential.TrustedDeviceCredentialModel; 11 | import nl.wouterh.keycloak.trusteddevice.credential.TrustedDeviceCredentialProvider; 12 | import nl.wouterh.keycloak.trusteddevice.credential.TrustedDeviceCredentialProviderFactory; 13 | import org.keycloak.TokenCategory; 14 | import org.keycloak.common.ClientConnection; 15 | import org.keycloak.common.util.Time; 16 | import org.keycloak.credential.CredentialProvider; 17 | import org.keycloak.models.KeycloakSession; 18 | import org.keycloak.models.RealmModel; 19 | import org.keycloak.models.UserModel; 20 | import org.keycloak.representations.JsonWebToken; 21 | 22 | @Getter 23 | @Setter 24 | @NoArgsConstructor 25 | public class TrustedDeviceToken extends JsonWebToken { 26 | 27 | public static final String COOKIE_NAME = "KEYCLOAK_TRUSTED_DEVICE"; 28 | 29 | public static void addCookie(KeycloakSession session, RealmModel realm, TrustedDeviceToken value, 30 | int maxAge) { 31 | addCookie(session, realm, session.tokens().encode(value), maxAge); 32 | } 33 | 34 | private static void addCookie(KeycloakSession session, RealmModel realm, String value, 35 | int maxAge) { 36 | UriBuilder baseUriBuilder = session.getContext().getUri().getBaseUriBuilder(); 37 | String path = baseUriBuilder.path("realms").path(realm.getName()).path("/").build().getPath(); 38 | 39 | ClientConnection connection = session.getContext().getConnection(); 40 | boolean secure = realm.getSslRequired().isRequired(connection); 41 | SameSite sameSiteValue = secure ? SameSite.NONE : null; 42 | NewCookie newCookie = new NewCookie.Builder(COOKIE_NAME) 43 | .maxAge(maxAge) 44 | .value(value) 45 | .path(path) 46 | .secure(secure) 47 | .sameSite(sameSiteValue) 48 | .build(); 49 | 50 | session.getContext().getHttpResponse().setCookieIfAbsent(newCookie); 51 | } 52 | 53 | public static TrustedDeviceToken getCookie(KeycloakSession session) { 54 | Cookie cookie = session.getContext().getRequestHeaders().getCookies().get(COOKIE_NAME); 55 | long time = Time.currentTime(); 56 | 57 | if (cookie == null) { 58 | return null; 59 | } 60 | 61 | TrustedDeviceToken decoded = session.tokens().decode(cookie.getValue(), TrustedDeviceToken.class); 62 | if (decoded != null && (decoded.getExp() == null || decoded.getExp() > time)) { 63 | return decoded; 64 | } 65 | 66 | return null; 67 | } 68 | 69 | public static TrustedDeviceCredentialModel getCredentialFromCookie(KeycloakSession session, 70 | RealmModel realm, UserModel user) { 71 | TrustedDeviceToken deviceToken = getCookie(session); 72 | TrustedDeviceCredentialProvider trustedDeviceCredentialProvider = (TrustedDeviceCredentialProvider) session 73 | .getProvider(CredentialProvider.class, TrustedDeviceCredentialProviderFactory.PROVIDER_ID); 74 | if (deviceToken == null) { 75 | return null; 76 | } 77 | 78 | TrustedDeviceCredentialModel credential = trustedDeviceCredentialProvider.getActiveCredentialById( 79 | realm, user, deviceToken.getId()); 80 | if (credential == null || !deviceToken.getSecret().equals(credential.getDeviceId())) { 81 | return null; 82 | } 83 | 84 | return credential; 85 | } 86 | 87 | public TrustedDeviceToken(String id, String secret, Long exp) { 88 | this.id = id; 89 | this.secret = secret; 90 | iat((long) Time.currentTime()); 91 | exp(exp); 92 | } 93 | 94 | @Override 95 | public TokenCategory getCategory() { 96 | return TokenCategory.INTERNAL; 97 | } 98 | 99 | private String id; 100 | 101 | private String secret; 102 | } 103 | -------------------------------------------------------------------------------- /spi/src/main/java/nl/wouterh/keycloak/trusteddevice/util/UserAgentParser.java: -------------------------------------------------------------------------------- 1 | package nl.wouterh.keycloak.trusteddevice.util; 2 | 3 | import jakarta.ws.rs.core.HttpHeaders; 4 | import org.keycloak.models.KeycloakSession; 5 | import ua_parser.Client; 6 | import ua_parser.Parser; 7 | 8 | public class UserAgentParser { 9 | 10 | private static Parser parser; 11 | 12 | public static synchronized Parser getParser() { 13 | if (parser == null) { 14 | parser = new Parser(); 15 | } 16 | 17 | return parser; 18 | } 19 | 20 | public static String getDeviceName(KeycloakSession session) { 21 | String userAgent = session.getContext().getRequestHeaders() 22 | .getHeaderString(HttpHeaders.USER_AGENT); 23 | 24 | if (userAgent == null) { 25 | return null; 26 | } 27 | 28 | if (userAgent.length() > 512) { 29 | return null; 30 | } 31 | 32 | Client parsed = getParser().parse(userAgent); 33 | return parsed.userAgent.family + " on " + parsed.os.family; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spi/src/main/resources/theme-resources/messages/messages_ca.properties: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | trusted-device-display-name=Dispositiu de confiança 3 | trusted-device-help-text=Els dispositius de confiança es comproven automàticament 4 | trusted-device-header=Confies en aquest dispositiu? 5 | trusted-device-yes=Sí 6 | trusted-device-no=No 7 | trusted-device-explanation=El segon factor ja no es demanarà en un dispositiu de confiança. No confieu mai en ordinadors públics o compartits. 8 | trusted-device-name=Nom d'aquest dispositiu 9 | -------------------------------------------------------------------------------- /spi/src/main/resources/theme-resources/messages/messages_de.properties: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | trusted-device-display-name=Vertrauenswürdiges Gerät 3 | trusted-device-help-text=Vertrauenswürdige Geräte werden automatisch überprüft 4 | trusted-device-header=Diesem Gerät vertrauen? 5 | trusted-device-yes=Ja 6 | trusted-device-no=Nein 7 | trusted-device-explanation=Der zweite Faktor wird auf einem vertrauenswürdigen Gerät nicht mehr angefordert. Vertrauen Sie niemals öffentlichen oder gemeinsam genutzten Computern. 8 | trusted-device-name=Name dieses Geräts 9 | -------------------------------------------------------------------------------- /spi/src/main/resources/theme-resources/messages/messages_en.properties: -------------------------------------------------------------------------------- 1 | trusted-device-display-name=Trusted device 2 | trusted-device-help-text=Trusted devices are verified automatically. 3 | trusted-device-header=Trust this device? 4 | trusted-device-yes=Yes 5 | trusted-device-no=No 6 | trusted-device-explanation=Trusted devices do not need a second factor. Do not trust public or shared machines. 7 | trusted-device-name=Name this device 8 | -------------------------------------------------------------------------------- /spi/src/main/resources/theme-resources/messages/messages_es.properties: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | trusted-device-display-name=Dispositivo de confianza 3 | trusted-device-help-text=Los dispositivos de confianza se verifican automáticamente 4 | trusted-device-header=¿Confiar en este dispositivo? 5 | trusted-device-yes=Sí 6 | trusted-device-no=No 7 | trusted-device-explanation=El segundo factor ya no se solicitará en un dispositivo de confianza. Nunca confíes en ordenadores públicos o compartidos. 8 | trusted-device-name=Nombre de este dispositivo 9 | -------------------------------------------------------------------------------- /spi/src/main/resources/theme-resources/messages/messages_fr.properties: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | trusted-device-display-name=Appareil de confiance 3 | trusted-device-help-text=Les appareils de confiance sont vérifiés automatiquement 4 | trusted-device-header=Faire confiance à cet appareil ? 5 | trusted-device-yes=Oui 6 | trusted-device-no=Non 7 | trusted-device-explanation=Le deuxième facteur ne sera plus demandé sur un appareil de confiance. Ne jamais faire confiance à des ordinateurs publics ou partagés. 8 | trusted-device-name=Nom de cet appareil 9 | -------------------------------------------------------------------------------- /spi/src/main/resources/theme-resources/messages/messages_it.properties: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | trusted-device-display-name=Dispositivo attendibile 3 | trusted-device-help-text=I dispositivi attendibili vengono controllati automaticamente 4 | trusted-device-header=Fidati di questo dispositivo? 5 | trusted-device-yes=Sì 6 | trusted-device-no=No 7 | trusted-device-explanation=Il secondo fattore non sarà più richiesto su un dispositivo attendibile. Non fidarti mai dei computer pubblici o condivisi. 8 | trusted-device-name=Nome di questo dispositivo 9 | -------------------------------------------------------------------------------- /spi/src/main/resources/theme-resources/templates/trusted-device-register.ftl: -------------------------------------------------------------------------------- 1 | <#import "template.ftl" as layout> 2 | <@layout.registrationLayout displayInfo=true; section> 3 | <#if section = "title"> 4 | <#elseif section = "header"> 5 | ${msg("trusted-device-header")} 6 | <#elseif section="form"> 7 |
10 |
11 |
12 |
13 |
14 |
15 | 16 | 28 | 29 | 31 | 32 |
33 | <#if (auth?has_content && auth.showUsername() && !auth.showResetCredentials())> 34 |

${msg("trusted-device-header")}

35 | 36 | 44 | 45 | 54 | 55 |
58 | ${msg("trusted-device-explanation")} 59 |
60 |
61 |
62 |
63 | 64 | 65 | --------------------------------------------------------------------------------