Skip to content

Commit d6a2210

Browse files
authored
Merge pull request #5587 from mpmadhavig/token-hashing
Add OAuth Token Hashing docs
2 parents f23589b + 26fb9e7 commit d6a2210

File tree

6 files changed

+88
-2
lines changed

6 files changed

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

en/identity-server/7.1.0/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,7 @@ nav:
11631163
- Token binding:
11641164
- Token binding: references/token-binding/index.md
11651165
- Client-request: references/token-binding/client-request.md
1166+
- Token hashing: references/token-hashing.md
11661167
- Financial-grade API: references/financial-grade-api.md
11671168
- App-native authentication: references/app-native-authentication.md
11681169
- OIDC session management: references/concepts/oidc-session-management.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% include "../../../../includes/references/token-hashing.md" %}

en/identity-server/next/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ nav:
12451245
- Token binding: references/token-binding/index.md
12461246
- Client-request: references/token-binding/client-request.md
12471247
- DPoP: references/token-binding/dpop.md
1248+
- Token hashing: references/token-hashing.md
12481249
- Financial-grade API: references/financial-grade-api.md
12491250
- App-native authentication: references/app-native-authentication.md
12501251
- OIDC session management: references/concepts/oidc-session-management.md
@@ -1345,7 +1346,6 @@ nav:
13451346
- Manage tokens in .NET: complete-guides/dotnet/manage-tokens-in-dotnet-apps.md
13461347
- Next Steps: complete-guides/dotnet/next-steps.md
13471348

1348-
13491349
not_in_nav: |
13501350
/page-not-found.md
13511351
/guides/authentication/add-identifier-first-login.md

en/includes/guides/authorization/user-impersonation/user-impersonation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ To make an application discoverable,
224224
225225
3. Click **Update** to save the changes.
226226
227-
### Step 4: Share Application with Organization(Optional)
227+
### Step 6: Share Application with Organization(Optional)
228228
229229
To allow impersonating organization users, share the business applications with the relevant organization. Use the [documentation here]({{base_path}}/guides/organization-management/share-applications/#share-a-registered-application) to proceed with configuring.
230230
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# OAuth Token Hashing
2+
3+
WSO2 Identity Server (WSO2 IS) allows you to enable OAuth2 token hashing to protect OAuth2 access tokens, refresh tokens, consumer secrets, and
4+
authorization codes.
5+
6+
!!! note
7+
- Token hashing is only required if there are long lived tokens.
8+
9+
- If you want to enable this feature, WSO2 recommends using a fresh
10+
WSO2 Identity Server distribution.
11+
12+
- To use this feature with an existing database, you may need to
13+
perform data migration before you enable the feature. If you have to
14+
perform data migration before you enable this feature, [Contact
15+
us](https://wso2.com/contact/).
16+
17+
----
18+
19+
## Set up OAuth token hashing
20+
21+
1. Add the following configurations to the `deployment.toml` file found in the `<IS_HOME>/repository/conf` folder.
22+
- Add the following property and set it to true to enable hashing.
23+
24+
``` toml
25+
[oauth]
26+
hash_tokens_and_secrets = true
27+
```
28+
29+
- Add the following configuration to specify the algorithm to use for hashing:
30+
31+
``` toml
32+
[oauth]
33+
hash_token_algorithm = "SHA-256"
34+
```
35+
36+
- Add the following token persistence processor to enable token hashing:
37+
38+
``` toml
39+
[oauth.extensions]
40+
token_persistence_processor = "org.wso2.carbon.identity.oauth.tokenprocessor.HashingPersistenceProcessor"
41+
```
42+
43+
!!! tip
44+
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).
45+
46+
The default algorithm for hashing is SHA-256.
47+
48+
2. Run the appropriate database command to remove the `CONN_APP_KEY` constraint from the `IDN_OAUTH2_ACCESS_TOKEN` table.
49+
50+
For example, if you are using an H2 database, you need to run the following command:
51+
52+
``` sql
53+
ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN DROP CONSTRAINT IF EXISTS CON_APP_KEY
54+
```
55+
56+
!!! tip
57+
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
58+
`IDN_OAUTH2_ACCESS_TOKEN` table enforces this by allowing only one active access token to exist for specified consumer key, user, and scope values.
59+
60+
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.
61+
62+
----
63+
64+
## Configure a service provider
65+
66+
Follow the steps below to register an application:
67+
68+
1. On the {{ product_name }} Console, go to **Applications**.
69+
70+
2. Click **New Application** and select **Standard-Based Application** to open the following:
71+
72+
![Register a standard based application]({{base_path}}/assets/img/apis/management-apis/register-a-sba.png){: width="600" style="display: block; margin: 0;"}
73+
74+
3. Provide an application name.
75+
76+
4. Select **OAuth 2.0 OpenID Connect** as the application protocol.
77+
78+
5. Click **Register** to complete the registration.
79+
80+
!!! tip
81+
The **Consumer Secret** value is displayed in plain text only once. Therefore, be sure to copy and save it for later use.
82+
83+
You have successfully set up OAuth token hashing. Now all of the OAuth2 access tokens, refresh tokens, consumer secrets, and authorization codes will be hashed in the database.

0 commit comments

Comments
 (0)