Skip to content

Instantly share code, notes, and snippets.

// To run this script, you can either:
// 1. Go to sessionize.com in your browser, open the browser console, and paste the following script
// 2. Run it locally in Node.JS and comment the following imports in the begining of the file to use JSDom as a dom parser.
// const jsdom = require("jsdom")
// const { JSDOM } = jsdom
// global.DOMParser = new JSDOM().window.DOMParser
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
const now = new Date();
const checkAvailability = new Promise((resolve) => {
const image = new Image();
const loadCB = function() {
resolve(image.height > 1);
}
image.onload = loadCB;
image.onerror = loadCB;
image.src = "https://youtube.com/favicon.ico";
});
@gemanor
gemanor / package.json
Created August 22, 2019 16:34
Package.json for social login
{
"name": "federated-id-service",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon index",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "[email protected]",
@gemanor
gemanor / passport.js
Created August 22, 2019 13:36
Passport.js file for social login demo
// Import all the
const passport = require('passport');
const GitHubStrategy = require('passport-github').Strategy;
const LinkedInStrategy = require('passport-linkedin-oauth2').Strategy;
const GoogleStrategy = require('passport-google-oauth20').Strategy;
const TwitterStrategy = require('passport-twitter').Strategy;
const Auth0Strategy = require('passport-auth0').Strategy;
module.exports = (app) => {
@gemanor
gemanor / index.js
Last active August 22, 2019 13:36
index.js for social login demo
// Import the .env file and assign all vars as env. vars
require('dotenv').config();
// Import required packages
var express = require('express');
var partials = require('express-partials')
var passportConfig = require('./src/passport');
const routes = require('./src/routes');
// Create a new Express application.
@gemanor
gemanor / .env
Created August 22, 2019 13:07
Env. variables for social login solution demo
NODE_TLS_REJECT_UNAUTHORIZED=0
ISE_ADDRESS=<Replace with the ISE PAN IP address>
ISE_SPONSOR_USER_NAME=<The sponsor-api username we will use to create guest users>
ISE_SPONSOR_PASSWORD=<The sponsor-api password we will use to create guest users>
SPONSOR_PORTAL_ID=<The self-registered portal ID you want the guest be created on>
LINKEDIN_CLIENT_ID=<your linkedin app client ID>
LINKEDIN_SECRET=<your linkedin app client secret>
GITHUB_CLIENT_ID=<your github app client ID>
GITHUB_SECRET=<your github app client secret>
GOOGLE_CLIENT_ID=<your google app client ID>