<commit_before># soajs.oauth
[![Build Status](https://travis-ci.org/soajs/soajs.oauth.svg?branch=master)](https://travis-ci.org/soajs/soajs.oauth)
[![Coverage Status](https://coveralls.io/repos/soajs/soajs.oauth/badge.png)](https://coveralls.io/r/soajs/soajs.oauth)
[![Known Vulnerabilities](https://snyk.io/test/github/soajs/soajs.oauth/badge.svg)](https://snyk.io/test/github/soajs/soajs.oauth)

SOAJS oAuth is a service that integrates with [oAuth 2.0](http://www.oauth.org).
The service simply validates, refreshes and kills access tokens generated via oAuth 2.0.

SOAJS oAuth is used to protect other services from public access.
Protected services are only accessible if the access_token generated by oAuth is provided as a parameter.


##Installation

```sh
$ npm install soajs.oauth
$ cd soajs.oauth
$ node .
```

---

##Features
Once Installed and running, the oAuth service offers 4 APIs:

1. Create Token: /token
2. Delete Access Token: /accessToken/:token
3. Delete Refresh Token: /refreshToken/:token
4. Delete all Tokens for a client: /tokens/:client

Login to oAuth and provide the credentials needed, then copy the access_token from the returned response.<br>
```bash
$ CURL -X POST -H "Authorization: Basic %encryptedBase64Value%" http://localhost:4000/oauth/token -d 'username=oauthuser&password=<PASSWORD>&grant_type=password'
```

Response:
```json
{
  "token_type": "bearer",
  "access_token": "<KEY>",
  "expires_in": 3600,
  "refresh_token": "bb09a2f5582425c4ef9440dcce5885cbbe743047"
}
```

In order to refresh the token:
```bash
$ CURL -X POST -H "Authorization: Basic %encryptedBase64Value%" http://localhost:4000/oauth/token -d 'grant_type=refresh_token&refresh_token=bb09a2f5582425c4ef9440dcce5885cbbe743047'
```

Use this access_token in all consequent requests that will be made to the protected service.
```bash
$ CURL -X GET -H "key:%someKeyValue%" "http://localhost:4000/example02/buildName?firstName=John&lastName=Smith&access_token=<KEY>"
```

Logout from oAuth by invoking the below API and the access_token will be killed.
```bash
$ CURL -X DELETE http://localhost:4000/oauth/accessToken/<KEY> -d 'access_token=<KEY>'
```

Similarly, to kill a refresh_token invoke the below API.
```bash
$ CURL -X DELETE http://localhost:4000/oauth/refreshToken/bb09a2f5582425c4ef9440dcce5885cbbe743047 -d 'access_token=<KEY>'
```

In order to delete all tokens of a certain user, invoke the below API.
```bash
$ CURL -X DELETE http://localhost:4000/oauth/tokens/user/%userID% -d 'access_token=<KEY>'
```

In order to delete all tokens of a certain client, invoke the below API.
```bash
$ CURL -X DELETE http://localhost:4000/oauth/tokens/tenant/%clientID% -d 'access_token=<KEY>'
```

---

More information is available on SOAJS website section for [oAuth](http://www.soajs.org/#/documentation/services/oauth).<commit_msg>updated reference link in readme file<commit_after># soajs.oauth
[![Build Status](https://travis-ci.org/soajs/soajs.oauth.svg?branch=master)](https://travis-ci.org/soajs/soajs.oauth)
[![Coverage Status](https://coveralls.io/repos/soajs/soajs.oauth/badge.png)](https://coveralls.io/r/soajs/soajs.oauth)
[![Known Vulnerabilities](https://snyk.io/test/github/soajs/soajs.oauth/badge.svg)](https://snyk.io/test/github/soajs/soajs.oauth)

SOAJS oAuth is a service that integrates with [oAuth 2.0](http://www.oauth.org).
The service simply validates, refreshes and kills access tokens generated via oAuth 2.0.

SOAJS oAuth is used to protect other services from public access.
Protected services are only accessible if the access_token generated by oAuth is provided as a parameter.


##Installation

```sh
$ npm install soajs.oauth
$ cd soajs.oauth
$ node .
```

---

##Features
Once Installed and running, the oAuth service offers 4 APIs:

1. Create Token: /token
2. Delete Access Token: /accessToken/:token
3. Delete Refresh Token: /refreshToken/:token
4. Delete all Tokens for a client: /tokens/:client

Login to oAuth and provide the credentials needed, then copy the access_token from the returned response.<br>
```bash
$ CURL -X POST -H "Authorization: Basic %encryptedBase64Value%" http://localhost:4000/oauth/token -d 'username=oauthuser&password=<PASSWORD>&grant_type=password'
```

Response:
```json
{
  "token_type": "bearer",
  "access_token": "<KEY>",
  "expires_in": 3600,
  "refresh_token": "bb09a2f55<PASSWORD>25c4<PASSWORD>440dcce5885cbbe743047"
}
```

In order to refresh the token:
```bash
$ CURL -X POST -H "Authorization: Basic %encryptedBase64Value%" http://localhost:4000/oauth/token -d 'grant_type=refresh_token&refresh_token=bb<PASSWORD>40dcce5<PASSWORD>cb<PASSWORD>'
```

Use this access_token in all consequent requests that will be made to the protected service.
```bash
$ CURL -X GET -H "key:%someKeyValue%" "http://localhost:4000/example02/buildName?firstName=John&lastName=Smith&access_token=<KEY>"
```

Logout from oAuth by invoking the below API and the access_token will be killed.
```bash
$ CURL -X DELETE http://localhost:4000/oauth/accessToken/<KEY> -d 'access_token=<KEY>'
```

Similarly, to kill a refresh_token invoke the below API.
```bash
$ CURL -X DELETE http://localhost:4000/oauth/refreshToken/<PASSWORD> -d 'access_token=<KEY>'
```

In order to delete all tokens of a certain user, invoke the below API.
```bash
$ CURL -X DELETE http://localhost:4000/oauth/tokens/user/%userID% -d 'access_token=<KEY>'
```

In order to delete all tokens of a certain client, invoke the below API.
```bash
$ CURL -X DELETE http://localhost:4000/oauth/tokens/tenant/%clientID% -d 'access_token=<KEY>'
```

---

More information is available on SOAJS website section for [oAuth](https://soajsorg.atlassian.net/wiki/spaces/OAUT/overview).
{'fraction_non_alphanumeric': 0.1369694843914416, 'fraction_numerical': 0.033847772711329355, 'mean_word_length': 5.185466377440347, 'pattern_counts': {'":': 8, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 13, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2781049', 'n_tokens_mistral': 2127, 'n_tokens_neox': 1924, 'n_words': 532}