https://github.com/ulbora/nodejsoauth2server
Oauth2 Server implementation in Node.js, enhanced JWT token, role and URL based security
https://github.com/ulbora/nodejsoauth2server
authorization oauth2 oauth2-server
Last synced: about 1 month ago
JSON representation
Oauth2 Server implementation in Node.js, enhanced JWT token, role and URL based security
- Host: GitHub
- URL: https://github.com/ulbora/nodejsoauth2server
- Owner: Ulbora
- License: agpl-3.0
- Created: 2016-12-08T02:44:46.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-23T23:57:10.000Z (almost 7 years ago)
- Last Synced: 2025-01-26T13:22:32.171Z (3 months ago)
- Topics: authorization, oauth2, oauth2-server
- Language: HTML
- Homepage: http://www.myapigateway.com
- Size: 966 KB
- Stars: 0
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://sonarcloud.io/dashboard?id=Oauth2Server)
[](https://sonarcloud.io/dashboard?id=Oauth2Server)Ulbora Oauth2 Server
==============Ulbora Oauth2 Server is an Oauth2 server implementation build on Node.js. Currently authorization code,
implicit, and client credentials grant types are supported.## Authorization Code Grant Type
* Authorize
```
Example
GET:http://localhost:3000/oauth/authorize?response_type=code&client_id=403&redirect_uri=CALLBACK_URL&scope=read&state=xyz
``````
Test
GET:http://localhost:3000/oauth/authorize?response_type=code&client_id=403&redirect_uri=http://www.google.com&scope=read&state=xyz
```
* Access Token
```
Example
POST:http://localhost:3000/oauth/token?client_id=403&client_secret=554444vfg55ggfff22454sw2fff2dsfd&grant_type=authorization_code&code=i76y13e340akRn6Ipkdbii&redirect_uri=http://www.google.com
``````
Test
POST:http://localhost:3000/oauth/token?client_id=403&client_secret=554444vfg55ggfff22454sw2fff2dsfd&grant_type=authorization_code&code=i76y13e340akRn6Ipkdbii&redirect_uri=http://www.google.com
```
* Refresh Token
```
Example
POST:http://localhost:3000/oauth/token?grant_type=refresh_token&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&refresh_token=REFRESH_TOKEN
``````
Test
POST:http://localhost:3000/oauth/token?grant_type=refresh_token&client_id=403&client_secret=554444vfg55ggfff22454sw2fff2dsfd&refresh_token=efssffffnnlf
```
## Implicit Grant Type
* Authorize
```
Example
GET:http://localhost:3000/oauth/authorize?response_type=token&client_id=403&redirect_uri=CALLBACK_URL&scope=read&state=xyz
``````
Test
GET:http://localhost:3000/oauth/authorize?response_type=token&client_id=403&redirect_uri=http://www.google.com&scope=read&state=xyz
```
## Client Credentials Grant Type
* Access Token
```
Example
POST:http://localhost:3000/oauth/token?client_id=403&client_secret=554444vfg55ggfff22454sw2fff2dsfd&grant_type=client_credentials
``````
Test
POST:http://localhost:3000/oauth/token?client_id=403&client_secret=554444vfg55ggfff22454sw2fff2dsfd&grant_type=client_credentials
```
## Password Grant Type
Currently not supported.## Access Token Validation
```
Example
POST:http://localhost:3000/rs/token/validate
``````
Request:{
"userId":null,
"clientId": 403,
"role":"admin",
"url":"http:localhost:3000/rs/updateClient",
"scope":null,
"accessToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhY2Nlc3MiLCJncmFudCI6ImNsaWVudF9jcmVkZW50aWFscyIsImNsaWVudElkIjo0MDMsInJvbGVVcmlzIjpbeyJjbGllbnRSb2xlSWQiOjEsInJvbGUiOiJhZG1pbiIsInVyaUlkIjo2MywidXJpIjoiaHR0cDpsb2NhbGhvc3Q6MzAwMC9ycy91cGRhdGVDbGllbnQiLCJjbGllbnRJZCI6NDAzfSx7ImNsaWVudFJvbGVJZCI6MSwicm9sZSI6ImFkbWluIiwidXJpSWQiOjc3LCJ1cmkiOiJodHRwOmxvY2FsaG9zdDozMDAwL3JzL2FkZENsaWVudFNjb3BlIiwiY2xpZW50SWQiOjQwM30seyJjbGllbnRSb2xlSWQiOjIsInJvbGUiOiJ1c2VyIiwidXJpSWQiOjY4LCJ1cmkiOiJodHRwOmxvY2FsaG9zdDozMDAwL3JzL2RlbGV0ZUNsaWVudEFsbG93ZWRVcmkiLCJjbGllbnRJZCI6NDAzfSx7ImNsaWVudFJvbGVJZCI6Miwicm9sZSI6InVzZXIiLCJ1cmlJZCI6ODAsInVyaSI6Imh0dHA6bG9jYWxob3N0OjMwMDAvcnMvYWRkQ2xpZW50Um9sZVVyaSIsImNsaWVudElkIjo0MDN9XSwiZXhwaXJlc0luIjozNjAwMCwiaWF0IjoxNDg3NTUwNTcxLCJ0b2tlblR5cGUiOiJhY2Nlc3MiLCJleHAiOjE0ODc1ODY1NzEsImlzcyI6IlVsYm9yYSBPYXV0aDIgU2VydmVyIn0.1Isnysob52ujgYOu9Oi"
}```
```
Response:{
"valid": true
}```
# Client Micro Service
Oauth2 Client Micro Service
## Headers
Content-Type: application/json (for POST and PUT)
Authorization: Bearer atToken
clientId: clientId (example 33477)## Add Client
```
POST:
URL: http://localhost:3000/rs/client/addExample Request
{
"name":"ulbora",
"webSite":"www.ulboralabs.com",
"email":"[email protected]",
"enabled":true,
"redirectUrls":[
{
"uri":"http://www.google.com",
"clientId":null
},
{
"uri":"http://www.ulboralabs.com",
"clientId":null
}
]
}
``````
Example Response{
"success": true,
"message": ""
}```
## Update Client
```
PUT:
URL: http://localhost:3000/rs/client/updateExample Request
{
"clientId": 510,
"name": "ulbora",
"webSite": "www.ulboralabs.com",
"email": "[email protected]",
"enabled": false
}
``````
Example Response{
"success": true,
"message": ""
}```
## Get Client
```
GET:
URL: http://localhost:3000/rs/client/get/510
``````
Example Response{
"id": 94,
"clientId": 510,
"name": "ulbora",
"webSite": "www.ulboralabs.com",
"email": "[email protected]",
"enabled": false}
```
## Get Client List
```
GET:
URL: http://localhost:3000/rs/client/list
``````
Example Response[
{
"id": 94,
"clientId": 510,
"name": "ulbora",
"webSite": "www.ulboralabs.com",
"email": "[email protected]",
"enabled": false}
]```
## Delete Client
```
DELETE:
URL: http://localhost:3000/rs/client/delete/509
``````
Example Response{
"success": true,
"message": ""
}```
## Add Client Grant Type
```
POST:
URL: http://localhost:3000/rs/clientGrantType/addExample Request
{
"grantType":"code",
"clientId":581
}
``````
Example Response{
"success": true,
"message": ""
}```
## Get Client Grant Type
```
GET:
URL: http://localhost:3000/rs/clientGrantType/list/581
``````
Example Response{
"grantType":"code",
"clientId":581
}```
## Delete Client Grant Type
```
DELETE:
URL: http://localhost:3000/rs/clientGrantType/delete/221
``````
Example Response{
"success": true,
"message": ""
}```
## Add Client Allowed URI
```
POST:
URL: http://localhost:3000/rs/clientAllowedUri/addExample Request
{
"uri":"www.ulboralabs.com",
"clientId":616
}
``````
Example Response{
"success": true,
"message": ""
}```
## Update Client Allowed URI
```
PUT:
URL: http://localhost:3000/rs/clientAllowedUri/updateExample Request
{
"uri":"www.ulbora.com",
"id":139
}
``````
Example Response{
"success": true,
"message": ""
}```
## Get Client Allowed URI
```
GET:
URL: http://localhost:3000/rs/clientAllowedUri/get/139
``````
Example Response{
"uri":"www.ulbora.com",
"id":139
}```
## Get Client Allowed URI List
```
GET:
URL: http://localhost:3000/rs/clientAllowedUri/list/616
``````
Example Response[
{
"uri":"www.ulbora.com",
"id":139
}
]```
## Delete Client Allowed URI
```
DELETE:
URL: http://localhost:3000/rs/clientAllowedUri/delete/139
``````
Example Response{
"success": true,
"message": ""
}```
## Add Client Redirect URI
```
POST:
URL: http://localhost:3000/rs/clientRedirectUri/addExample Request
{
"uri":"www.ulboralabs.com",
"clientId":616
}
``````
Example Response{
"success": true,
"message": ""
}```
## Get Client Redirect URI List
```
GET:
URL: http://localhost:3000/rs/clientRedirectUri/list/616
``````
Example Response[
{
"uri":"www.ulbora.com",
"id":139
}
]```
## Delete Client Redirect URI
```
DELETE:URL: http://localhost:3000/rs/clientRedirectUri/delete/681
``````
Example Response{
"success": true,
"message": ""
}```
## Add Client Role
```
POST:
URL: http://localhost:3000/rs/clientRole/addExample Request
{
"role":"tester2",
"clientId":616
}
``````
Example Response{
"success": true,
"message": ""
}```
## Get Client Role List
```
GET:
URL: http://localhost:3000/rs/clientRole/list/616
``````
Example Response[
{
"role":"tester2",
"clientId":616
}
]```
## Delete Client Role
```
DELETE:URL: http://localhost:3000/rs/clientRole/delete/25
``````
Example Response{
"success": true,
"message": ""
}```
## Add Client Role URI
```
POST:
URL: http://localhost:3000/rs/clientRoleUri/addExample Request
{
"clientRoleId":24,
"clientAllowedUriId":167
}
``````
Example Response{
"success": true,
"message": ""
}```
## Get Client Role URI List
```
GET:
URL: http://localhost:3000/rs/clientRoleUri/list/24
``````
Example Response[
{
"clientRoleId":24,
"clientAllowedUriId":167
}
]```
## Delete Client Role URI
```
DELETE:URL: http://localhost:3000/rs/clientRoleUri/delete
``````
Example Response{
"success": true,
"message": ""
}```