Giter VIP home page Giter VIP logo

bearer-auth-api's Introduction

bearer-auth-api

REST API server using gin-gonic to check "Authorization: Bearer" header.

TravisCI Status DockerHub Status

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.
  2. If Token does not be found in AUTH_TOKENS JSON which is given from the environment variable, respond 401 Unauthorized.
  3. If Token is found, but path does not be allowed, respond 403 Forbidden
  4. If Token is found and path is allowed, respond 200 OK

This REST API is assumed to use with Ambassador on Kubernetes.

AUTH_TOKENS JSON template

{
  "<token1>": ["<allowed path regex>", "<allowed path regex>"...],
  "<token2>": [...],
  ...
}

example)

{
  "Znda7iglaqdoltsp7kDl60TvkkszcEGU": ["^/path1/.*$", "^/path2/path2-2/.*$"],
  "fANtLRTszYAayjtmLFllSHBrt2zRyoqV": ["^/path2/.*$"]
}

Run as Docker container

  1. Pull container nmatsui/bearer-auth-api from DockerHub

    $ docker pull nmatsui/bearer-auth-api
  2. Run Container

    • If you want to change exposed port, set LISTEN_PORT environment variable.
    $ docker run -d -p 3000:3000 nmatsui/bearer-auth-api

Build from source code

  1. go get

    $ go get -u github.com/nmatsui/bearer-auth-api
  2. go install

    $ go install github.com/nmatsui/bearer-auth-api

License

Apache License 2.0

Copyright

Copyright (c) 2018 Nobuyuki Matsui [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.