GithubHelp home page GithubHelp logo

2coo / authserver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from esarafianou/authserver

0.0 0.0 0.0 271 KB

Example of an OAuth2 authorization server using Express, passport, oauth2orize and Postgres for backend and React for the UI

JavaScript 100.00%

authserver's Introduction

OAuth2 authorization server

Example of an OAuth2 authorization server using Express, oauth2orize, passport and Postgres for backend and React for the UI

This repo is an example of an OAuth2 authorization server. When a client application supports login with this authorization server, the user will be redirected to a URL similar to this:

http://localhost:3000/oauth?clientID=12345678&redirectURI=https://auth0.com&response_type=code&scope=openid profile email&state=poicdcwefcd

The user will need to login to the authorization server and grant permission, so that he/she is redirected to the client application with an authorization code. At this point, the client application will establish a second channel with the authorization server to exchange the code with an acess token. Using the access token, the client application can make a request to /userinfo and get information about the user according to the scope that was set when requesting an authorization grant.

If the user is already logged in the login page will be skipped. If the user has already grant permission, the consent page will also be skipped.

The authorization server also supports login with Google and GitHub. For that, the authorzation server should be registered as a client application to Google /GitHub and the corresponding client_id and client_secret should be added as environment variables.

How to run

  • npm install
  • docker_db: A postgres database will be created in a docker container
  • node testing_data: A new client application will be registered
  • npm start: Start backend server
  • npm run devserver: Start frontend server

Back channel Communication

  • ./backchannel code <value> : Exchange auth code with access token
  • ./backchannel refresh_token <value>: Exchange refresh token with access token
  • ./backchannel userinfo <value>: Get user information. is a valid access token

Technologies

  • Backend
    • express server
    • passport for the authentication
    • oauth2orize for the OAuth2
    • postgres database
    • sequelize for ORM
  • Frontend
    • React for the UI
    • axios for the HTTP client

authserver's People

Contributors

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