https://github.com/zemuldo/authentication-methods
https://github.com/zemuldo/authentication-methods
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/zemuldo/authentication-methods
- Owner: zemuldo
- License: apache-2.0
- Created: 2021-01-28T22:09:41.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-09T18:59:11.000Z (over 5 years ago)
- Last Synced: 2025-07-14T20:08:59.593Z (11 months ago)
- Language: JavaScript
- Size: 24.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zemuldo-authentication-methods
To start, clone repo then:
Run `npm install`
Run `npm start`
## Basic Auth
Call endpoint with credentials.
Example:
```shell
curl --request GET \
--url http://localhost:4000/basic \
--header 'Authorization: Basic emVtdWxkbzpwYXNzd29yZA=='
```
## Bearer Token
### RS256
Run auth request
```shell
curl --request POST \
--url http://localhost:4000/bearer-token/rsa-sha-256/signin \
--header 'Content-Type: application/json' \
--data '{
"username": "zemuldo",
"password": "password"
}'
```
Response to this will look like
```json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2V..."
}
```
Use the token to call a protected endpoint
```shell
curl --request GET \
--url http://localhost:4000/bearer-token/rsa-sha-256/protected \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1...'
```
### HS256
Login request
```sehll
curl --request POST \
--url http://localhost:4000/bearer-token/hmac-sha-256/signin \
--header 'Content-Type: application/json' \
--data '{
"username": "zemuldo",
"password": "password"
}'
```
Response to this will look like
```json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2V..."
}
```
Use the token to access protected endpoint
```shell
curl --request GET \
--url http://localhost:4000/bearer-token/hmac-sha-256/protected \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2...'
```