pieterdewachter / angular-github-auth

Authentication with GitHub in Angular

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Angular GitHub Auth

The project is a rewrite on Makerlog's approach for using gatekeeper GitHub-authentication. Instead of plain Javascript we use Angular.

This project was generated with angular-cli version 1.0.0-beta.28.3 and gatekeeper.

Install npm packages to run angular-cli

  1. Install
npm install
  1. Run the application
ng serve

Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Setup your GitHub Application

  1. Sign in into GitHub
  2. Go to settings/OAuth applications and Register a new application
  3. Give your application a name and fill in the Homepage URL and Authorization callback URL : http://localhost:4200/
  4. Save (afterwards we will need the Client ID and Client Secret for our gatekeeper setup)

Setup Gatekeeper

  1. Clone the repository into src/app/shared directory
git clone git@github.com:prose/gatekeeper.git
  1. Install Dependencies
cd src/app/shared && npm install
  1. Adjust config.json (src/app/shared/gatekeeper/config.json)
{
 "oauth_client_id": "GITHUB_APPLICATION_CLIENT_ID",
 "oauth_client_secret": "GITHUB_APPLICATION_CLIENT_SECRET",
 "oauth_host": "github.com",
 "oauth_port": 443,
 "oauth_path": "/login/oauth/access_token",
 "oauth_method": "POST",
 "port": 9999
}
  1. Adjust gatekeeper.config.ts (src/app/gatekeeper.config.ts)
export const gatekeeperConfig = {
  development: {
    client_id: 'GITHUB_APPLICATION_CLIENT_ID',
    redirect_uri: 'http://localhost:4200/auth',
    gatekeeper: 'http://localhost:9999'
  },
  production: {}
};
  1. Add Gatekeeper to .gitignore

  2. Serve

$ cd src/app/shared/gatekeeper && node server.js

About

Authentication with GitHub in Angular


Languages

Language:TypeScript 79.4%Language:JavaScript 11.2%Language:HTML 5.9%Language:CSS 3.5%