GithubHelp home page GithubHelp logo

hhy5277 / micro-auth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hypebeast/micro-auth

0.0 2.0 0.0 10 KB

A microservice that makes adding authentication with Google and Github to your application easy.

License: MIT License

Lua 73.41% Shell 11.26% Nginx 15.33%

micro-auth's Introduction

micro-auth

A microservice that makes adding authentication with Google or Github to your application easy.

This service allows you to use Google and Github OAuth2 service to add authentication to your applications in a very straightforward way.

It's build with Nginx/OpenResty, Lapis and Docker. This enables the service to be very performant and requires only minimal system resources.

Features

Getting started

  • Install (if you don't have them):
  • Setup required environment variables
  • Run in development mode:
    • Run the application with docker-compose -f docker-compose-dev.yml up
  • Run in production mode:
    • Run the application with docker-compose up
  • Once micro-auth is running, you can point your login to one of the following urls (URLs are for development mode):
    • http://localhost:8080/auth/github: For Github login
    • http://localhost:8080/auth/google: For Google login

Authentication Services

Google

Setup

Visit Google Developers Console and create a new application on Google. Then go to Credentials and create a new OAuth Client ID. Now, get the Client ID and Client secret.

Endpoints

  • http://localhost:8080/auth/google: Endpoint for Google authentication. Point your application to this endpoint to login with Google.

Results

After successfull authentication with Google the user is redirect to the URL specified in GOOGLE_REDIRECT_URL with the access token saved in the access_token query parameter.

Github

Setup

Visit Github and create a new application on Github to get your client id and secret.

Endpoints

  • http://localhost:8080/auth/github: Endpoint for Github authentication. Point your application to this endpoint to login with Github.

Results

After successfull authentication with Github the user is redirect to the URL specified in GITHUB_REDIRECT_URL with the access token saved in the access_token query parameter.

Environment variables

To use the service you must set some required environment variables. These variables can be set in the .env file. Just copy .env.example to .env

$ cp .env.example .env

end set the required variables.

Secrets in docker swarm

Setting the above environment variables with _FILE pointed at the secret mount inside the container. -e GOOGLE_SECRET_FILE=/run/secrets/google_secret. This will set the contents on the file as the value of the environment variable.

General

  • APP_URL: Specify the URL of micro-auth (default: http://localhost:8080 in development mode). The APP_URL must be set in production mode.

Google

  • GOOGLE_CLIENT_ID: The Google application client id (required)
  • GOOGLE_CLIENT_SECRET: The Google application client secret (required)
  • GOOGLE_REDIRECT_URL: The url to redirect the user once the authentication was successfull

Github

  • GITHUB_CLIENT_ID: The Github application client id (required)
  • GITHUB_CLIENT_SECRET: The Github application client secret (required)
  • GITHUB_REDIRECT_URL: The url to redirect the user once the authentication was successfull

License

See LICENSE

Credits

micro-auth's People

Contributors

1000hz avatar 7imbrook avatar hypebeast avatar

Watchers

 avatar  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.