AngularJS-JWT-OAuth2-Demo
AngularJS-JWT-OAuth2-Demo copied to clipboard
An app demonstrating signing-in via Facebook, using JWT for authentication and front-end login redirect using UI Router
AngularJS-JWT-OAuth2-Demo
An app to demonstrate authorization and authentication built on top of MEAN stack.
Demo: http://www.sumeetdas.me
Click on 'Contact' (which you can find it on Navbar) and you will see the login drop down menu. Click on any of the buttons to login in to the application via the chosen OAuth2 provider and you'll be redirected to Contact page.
Features of this app include:
- Authentication using JWT (JSON Web Tokens)
- Using popup windows for OAuth 2.0 authentication
- User can either login via OAuth 2.0 or can login after signing up for a new user account (if one does not exist already)
- Some views may require login. Such scenarios are handled in the front-end itself by redirecting the user to login view and after successful login, the user is redirected back to the original view.
- Front-end technologies include:
- Angular
- Angular Bootstrap
- Angular UI Router
- Angular JWT (for decoding JWT tokens received from the server and sending them in every request to the server)
- ngStorage (for storing the JWT tokens)
- Font Awesome for displaying various icons
- Back-end technologies include:
- Express
- Mongoose
- Passport
- Jade Templating Engine
- jsonwebtoken (jwt utility library)
- Various Passport strategies for different OAuth 2.0 providers
Important Note: Since passport strategy for Twitter OAuth 1.0 a requires session support, I have decided not to include Twitter login.
Installation
- Download the repository
- Install npm modules: npm install
- Install bower modules: bower install
- Install mongodb server (if you haven't already) and start it
- Update config/mongo.json file with prod and dev mongodb config
- Update config/passport.json file with prod and dev OAuth2 config data for different providers
- Update config/token.json file with your own custom secret (to be used in JWT sent after a user is successfully logged in)
TODOs
- Test cases
- Docs