Skip to content

Commit f6963cd

Browse files
authored
Merge pull request #6109 from Thumimku/clientSecret-master
[Next] Client secret hash
2 parents f5b48c9 + 378e1f7 commit f6963cd

4 files changed

Lines changed: 113 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% include "../../../../includes/references/client-secret-and-token-hashing.md" %}

en/identity-server/next/docs/references/token-hashing.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

en/identity-server/next/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ nav:
14611461
- Token binding: references/token-binding/index.md
14621462
- Client-request: references/token-binding/client-request.md
14631463
- DPoP: references/token-binding/dpop.md
1464-
- Token hashing: references/token-hashing.md
1464+
- Client Secret & Token hashing: references/client-secret-and-token-hashing.md
14651465
- Financial-grade API: references/financial-grade-api.md
14661466
- App-native authentication: references/app-native-authentication.md
14671467
- OIDC session management: references/concepts/oidc-session-management.md
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# OAuth Client Secret and Token Hashing
2+
3+
WSO2 Identity Server (WSO2 IS) lets you protect sensitive OAuth2 data at rest by enabling hashing. Two modes are supported:
4+
5+
- **Full hashing** — hash OAuth2 access tokens, refresh tokens, consumer secrets (client secrets), and authorization codes.
6+
- **Client-secret-only hashing** — hash only consumer secrets (client secrets), leaving tokens and authorization codes unhashed.
7+
8+
If full hashing is enabled, it takes precedence; the client-secret-only configuration has no additional effect in that case.
9+
10+
!!! note
11+
- Token hashing is only required if there are long lived tokens.
12+
13+
- If you want to enable this feature, WSO2 recommends using a fresh
14+
WSO2 Identity Server distribution.
15+
16+
- To use this feature with an existing database, you may need to
17+
perform data migration before you enable the feature. If you have to
18+
perform data migration before you enable this feature, [Contact
19+
us](https://wso2.com/contact/).
20+
21+
----
22+
23+
## Set up OAuth token and client secret hashing
24+
25+
1. Add the following configurations to the `deployment.toml` file found in the `<IS_HOME>/repository/conf` folder.
26+
- Add the following property and set it to true to enable hashing.
27+
28+
``` toml
29+
[oauth]
30+
hash_tokens_and_secrets = true
31+
```
32+
33+
- Add the following configuration to specify the algorithm to use for hashing:
34+
35+
``` toml
36+
[oauth]
37+
hash_token_algorithm = "SHA-256"
38+
```
39+
40+
- Add the following token persistence processor to enable token hashing:
41+
42+
``` toml
43+
[oauth.extensions]
44+
token_persistence_processor = "org.wso2.carbon.identity.oauth.tokenprocessor.HashingPersistenceProcessor"
45+
```
46+
47+
!!! tip
48+
WSO2 Identity Server allows you to use hashing algorithms supported by MessageDigest. For more information on hashing algorithms supported by MessageDigest, see [MessageDigest Algorithms](https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest).
49+
50+
The default algorithm for hashing is SHA-256.
51+
52+
2. Run the appropriate database command to remove the `CONN_APP_KEY` constraint from the `IDN_OAUTH2_ACCESS_TOKEN` table.
53+
54+
For example, if you are using an H2 database, you need to run the following command:
55+
56+
``` sql
57+
ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN DROP CONSTRAINT IF EXISTS CON_APP_KEY
58+
```
59+
60+
!!! tip
61+
In general, for a specified consumer key, user, and scope, there can be only one active access token. The `CON_APP_KEY` constraint in the
62+
`IDN_OAUTH2_ACCESS_TOKEN` table enforces this by allowing only one active access token to exist for specified consumer key, user, and scope values.
63+
64+
With regard to hashing, a new access token is issued for every access token request. Therefore, for a given consumer key, user, and scope, there can be multiple active access tokens. To allow existence of multiple active access tokens, you need to remove the `CONN_APP_KEY` constraint from the `IDN_OAUTH2_ACCESS_TOKEN` table.
65+
66+
----
67+
68+
## Set up client secret hashing only
69+
70+
Use this mode to enable hashing for client secrets only, while leaving access tokens, refresh tokens, and authorization codes in their existing form. This mode is disabled by default. If full hashing is already enabled, it takes precedence and this configuration has no additional effect.
71+
72+
1. Add the following configurations to the `deployment.toml` file found in the `<IS_HOME>/repository/conf` folder.
73+
74+
``` toml
75+
[oauth]
76+
hash_client_secret = true
77+
client_secret_hash_algorithm = "SHA-256"
78+
79+
[oauth.extensions]
80+
client_secret_persistence_processor = "org.wso2.carbon.identity.oauth.tokenprocessor.HashingPersistenceProcessor"
81+
```
82+
83+
!!! note
84+
- `hash_client_secret` defaults to `false`.
85+
- `client_secret_hash_algorithm` defaults to `SHA-256`. WSO2 Identity Server allows you to use hashing algorithms supported by MessageDigest. For more information on hashing algorithms supported by MessageDigest, see [MessageDigest Algorithms](https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest).
86+
87+
!!! warning
88+
Enabling this feature does **not** hash client secrets that are already stored in the database. A separate migration is required to hash previously stored client secrets. See the [client secret hashing migration scripts](https://github.com/wso2-extensions/identity-inbound-auth-oauth/tree/master/features/org.wso2.carbon.identity.oauth.server.feature/resources/dbScripts/storedProcedure/HashClientSecret) for details.
89+
90+
----
91+
92+
## Configure a service provider
93+
94+
Follow the steps below to register an application:
95+
96+
1. On the {{ product_name }} Console, go to **Applications**.
97+
98+
2. Click **New Application** and select **Standard-Based Application** to open the following:
99+
100+
![Register a standard based application]({{base_path}}/assets/img/apis/management-apis/register-a-sba.png){: width="600" style="display: block; margin: 0;"}
101+
102+
3. Provide an application name.
103+
104+
4. Select **OAuth 2.0 OpenID Connect** as the application protocol.
105+
106+
5. Click **Register** to complete the registration.
107+
108+
!!! tip
109+
The **Consumer Secret** value is displayed in plain text only once. Therefore, be sure to copy and save it for later use.
110+
111+
You have successfully set up OAuth hashing. Depending on the mode you configured, the corresponding OAuth2 artifacts (all tokens and secrets, or client secrets only) will now be hashed in the database.

0 commit comments

Comments
 (0)