Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github-auth

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-auth - npm Package Compare versions

Comparing version 0.3.6 to 0.4.0

6

examples/express3.js

@@ -19,8 +19,6 @@ var express = require('express');

app.get('/login', function(req, res) {
res.send('You are not logged in <br /><a href="'+gh.loginUrl+'">Login</a>');
});
app.get('/login', gh.login);
app.get('*', function(req, res, next) {
if (!req.github) return res.redirect('/login');
if (!req.github) return res.send('<a href="/login">Please login</a>');
if (!req.github.authenticated) return res.send(404, 'YOU SHALL NOT PASS');

@@ -27,0 +25,0 @@ next();

var root = require('root');
var github = require('github-auth');
var app = root();
var gh = github('blah', 'blehbleh', {
users: ['sorribas']
});
app.get('/login', function(req, res) {
res.send('<a href="'+gh.loginUrl+'">Login</a>');
});
app.get('/login', gh.login);
app.all('*', gh.authenticate);
app.all('*', function(req, res, next) {
if (!req.github) return res.redirect('/login');
if (!req.github) return res.send('<a href="/login">Please login</a>');
if (!req.github.authenticated) return res.send('You shall not pass');
next();
});
app.get('/', function(req, res) {
res.send('<h2>Hello World!</h2>');
});
app.listen(3000);

@@ -17,2 +17,8 @@ var routilCookie = require('routil-cookie');

var toFunction = function(str) {
return function() {
return str;
};
};
module.exports = function(clientId, clientSecret, config) {

@@ -25,2 +31,4 @@ var scope = (config.team && !config.credentials) ? 'user' : 'public';

if (typeof redirectUri !== 'function') redirectUri = toFunction(redirectUri);
var getRequest = function(url, forceOauth, cb) {

@@ -150,6 +158,8 @@ if (typeof forceOauth === 'function') {

var ghUrl = 'https://github.com/login/oauth/authorize?client_id='+clientId+ '&scope=' + scope + '&redirect_uri=' + redirectUri;
var ghUrl = function(req) {
return 'https://github.com/login/oauth/authorize?client_id='+clientId+ '&scope=' + scope + '&redirect_uri=' + redirectUri(req);
};
var login = function(req, res, next) {
redirect(ghUrl, res);
redirect(ghUrl(req), res);
};

@@ -179,3 +189,3 @@

if (!u.query.code) {
if (config.autologin) return redirect(ghUrl, res);
if (config.autologin) return redirect(ghUrl(req), res);
delete req.github;

@@ -230,3 +240,2 @@ return next();

login: login,
loginUrl: ghUrl,
logout: logout

@@ -233,0 +242,0 @@ };

{
"name": "github-auth",
"version": "0.3.6",
"version": "0.4.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc