https://github.com/athiththan11/sample-apimtokenissuer
A simple custom APIM Token Issuer Implementation
https://github.com/athiththan11/sample-apimtokenissuer
apim-token-issuer issuer wso2 wso2-apimanager
Last synced: 2 months ago
JSON representation
A simple custom APIM Token Issuer Implementation
- Host: GitHub
- URL: https://github.com/athiththan11/sample-apimtokenissuer
- Owner: athiththan11
- Created: 2019-12-26T07:56:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-26T09:04:06.000Z (over 5 years ago)
- Last Synced: 2025-01-01T07:27:07.146Z (4 months ago)
- Topics: apim-token-issuer, issuer, wso2, wso2-apimanager
- Language: Java
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Custom APIM Token Issuer
A sample extended `APIMTokenIssuer` implementation to append a custom value to the generated Opaque Access Tokens.
[A Medium Blog: Customizing Opaque Access Token Generation](https://medium.com/@athiththan11/customizing-opaque-access-token-generation-58ec7e493405)
## Implementation
This is a sample implementation to demonstrate on how-to extract a custom header sent to with the `Token` request and append it to the generate Opaque access token.
The custom header used here is called as `devhash` which is a hash value as `data-urlencode` with the `Token` request.
Given below is a sample `/token` requst
```http
POST https://localhost:8243/tokenAuthorization: Basic
Content-Type: application/x-www-form-urlencodedgrant_type=password
username=admin
password=admin
scope=defualt
devhash=af1c4ca13ab7d6c8d2a887d7ce8250a2
``````curl
curl --location --request POST 'https://localhost:8243/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=admin' \
--data-urlencode 'scope=default' \
--data-urlencode 'devhash=af1c4ca13ab7d6c8d2a887d7ce8250a2'
```And the response should be as follows...
```json
{
"access_token": "25b9ded7-7441-3b69-bb6b-b1f1828bfff9af1c4ca13ab7d6c8d2a887d7ce8250a2",
"refresh_token": "d86ac9b8-a3aa-3664-9d39-090ca49a9435",
"scope": "default",
"token_type": "Bearer",
"expires_in": 3600
}
```## Build, Deploy & Run
### Build
Execute the following command to build the project
```shell
mvn clean package
```### Deploy
Copy and place the built JAR artifact from the `/target/custom-apimtoken-issuer-x.x.x.jar` to the `/repository/components/lib` directory. And then navigate to `/repository/conf/identity/identity.xml` and edit the `` with the custom package...
```xml
...
com.athiththan.token.MyAPIMTokenIssuer
...```