GithubHelp home page GithubHelp logo

shivanshkc / authorizer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 125 KB

A dead simple authorization service that uses OAuth.

Home Page: https://authorizer.rudraksh.dev

License: MIT License

Dockerfile 1.49% Makefile 4.55% Go 93.96%
cloud-run oauth2

authorizer's Introduction

Authorizer

Introduction

Authorizer is a dead simple authentication and authorization service based on OAuth.

Deployment

To run an Authorizer instance, follow these steps:

  1. Clone the Repository:

    git clone [email protected]:shivanshkc/authorizer.git
    cd authorizer
  2. Build the Container Image:

    make image
  3. Run the Container:

    docker run \
      --detach \
      --name authorizer \
      --net host \
      --volume <config file local path>:/etc/authorizer/configs.yaml \
      authorizer:latest
  4. Configuration:

    • Authorizer accepts configuration in YAML format.
    • Refer to configs/configs.sample.yaml for the configuration schema.

API Documentation

Start Authentication Flow

Endpoint: GET /api/auth/{provider}

Parameters:

  • Path Parameter:
    • provider: Specifies the OAuth provider. The only supported provider currently is google.
  • Query Parameter:
    • redirect_uri: The URL where the user will be redirected after authentication. Ensure this URL is in the allowed list in the application config before use.

Authentication Result

  • Success: The final URL will contain an id_token query parameter, which is a JWT that can be decoded to retrieve user details.
  • Failure: The final URL will contain an error query parameter with the failure reason.

Get Self Details

Endpoint: GET /api/user

Parameters:

  • Headers:
    • Authorization: The access token obtained using the auth API.

Success Response

{
    "_id": "6683b25382af3a39b661ee2f", // Hex code
    "email": "[email protected]", // Email used during OAuth
    "first_name": "John", 
    "last_name": "Doe",
    "picture_link": "https://photos.com/abc", // Picture link as obtained from the provider.
    "created_at": "2024-07-02T07:54:59.125Z",
    "updated_at": "2024-07-04T18:58:01.891Z"
}

Error Responses

  • 401 if the access token is absent or malformed.
  • 404 if the user does not exist.
  • 500 if an unexpected error occurs.

Note: The /api/user route can also be invoked using the HEAD verb which will not return the user's details, but it can be used to check the validity of the token. Also, it works much faster than the GET one.

Get User

Endpoint: GET /api/user/{email}

Parameters:

  • Headers:
    • Authorization: The access token obtained using the auth API.
  • Path:
    • email: Email of the user to be fetched.

Success Response

{
    "_id": "6683b25382af3a39b661ee2f", // Hex code
    "email": "[email protected]",
    "first_name": "John", 
    "last_name": "Doe",
    "picture_link": "https://photos.com/abc", // Picture link as obtained from the provider.
    "created_at": "2024-07-02T07:54:59.125Z",
    "updated_at": "2024-07-04T18:58:01.891Z"
}

Error Responses

  • 401 if the access token is absent or malformed.
  • 404 if the user does not exist.
  • 500 if an unexpected error occurs.

authorizer's People

Contributors

shivanshkc avatar semantic-release-bot avatar

Watchers

 avatar

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.