🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

github-admin-login

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-admin-login

HTTP auth module to require admin page users to be in a Github org

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

github-admin-login

HTTP auth module to require admin page users to be in a Github org

npm install github-admin-login

Usage

const adminLogin = require('github-admin-login')
const http = require('http')

const login = adminLogin({
  clientId: githubOauthClientId,
  clientSecret: githubOauthClientSecret,
  users: [
    'mafintosh' // users that are allowd to login
  ]
})

http.createServer(function (req, res) {
  login(req, res, function (err, username) {
    if (err) throw err
    console.log('valid login from', username)
  })
}).listen(10000)

API

login = adminLogin(opts)

Create a Github admin login http handler.

Options include:

{
  clientId: githubOauthClientId,
  clientSecret: githubOauthClientSecret,
  users: optionalArrayOfValidUsers,
  organization: optionalValidGithubOrg
}

You can get the clientId and clientSecret by making a new OAuth app on your Github org or user profile. Make sure to set the callback url to the root of your website.

Only users in the users array of users who are in the org specified will be allowed to login.

If a non valid user logs in the server will return a 403.

username = login.decode(req)

Returns the Github username of the current user logged in.

License

MIT

FAQs

Package last updated on 06 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts