https://github.com/nmatsui/bearer-auth-api
REST API server using gin-gonic to check "Authorization: Bearer" header.
https://github.com/nmatsui/bearer-auth-api
ambassador gin-gonic golang
Last synced: 2 months ago
JSON representation
REST API server using gin-gonic to check "Authorization: Bearer" header.
- Host: GitHub
- URL: https://github.com/nmatsui/bearer-auth-api
- Owner: nmatsui
- License: apache-2.0
- Created: 2018-04-19T09:59:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-28T10:24:07.000Z (over 7 years ago)
- Last Synced: 2025-06-11T07:51:15.521Z (4 months ago)
- Topics: ambassador, gin-gonic, golang
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bearer-auth-api
REST API server using gin-gonic to check "Authorization: Bearer" header.[](https://travis-ci.org/nmatsui/bearer-auth-api)
[](https://hub.docker.com/r/nmatsui/bearer-auth-api/builds/)## Description
This REST API Server receives any path and any methods, and checks Bearer Token ("Authorization: Bearer *TOKEN*" Request Header).1. If no Bearer Token, respond `401 Unauhtorized` always.
1. If Token does not be found in `AUTH_TOKENS` JSON which is given from the environment variable, respond `401 Unauthorized`.
1. If Token is found, but path does not be allowed, respond `403 Forbidden`
1. If Token is found and path is allowed, respond `200 OK`This REST API is assumed to use with [Ambassador](https://www.getambassador.io/) on [Kubernetes](https://www.getambassador.io/).
## `AUTH_TOKENS` JSON template
```text
{
"": ["", ""...],
"": [...],
...
}
```example)
```json
{
"Znda7iglaqdoltsp7kDl60TvkkszcEGU": ["^/path1/.*$", "^/path2/path2-2/.*$"],
"fANtLRTszYAayjtmLFllSHBrt2zRyoqV": ["^/path2/.*$"]
}
```## Run as Docker container
1. Pull container [nmatsui/bearer-auth-api](https://hub.docker.com/r/nmatsui/bearer-auth-api/) from DockerHub
```bash
$ docker pull nmatsui/bearer-auth-api
```
1. Run Container
* If you want to change exposed port, set `LISTEN_PORT` environment variable.```bash
$ docker run -d -p 3000:3000 nmatsui/bearer-auth-api
```## Build from source code
1. go get
```bash
$ go get -u github.com/nmatsui/bearer-auth-api
```
1. go install```bash
$ go install github.com/nmatsui/bearer-auth-api
```## License
[Apache License 2.0](/LICENSE)
## Copyright
Copyright (c) 2018 Nobuyuki Matsui