Skip to content

Instantly share code, notes, and snippets.

View saltukalakus's full-sized avatar
💭

Saltuk Alakus saltukalakus

💭
View GitHub Profile
var crypto = require('crypto');
function base64URLEncode(str) {
return str.toString('base64')
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
}
var verifier = base64URLEncode(crypto.randomBytes(32));
function (user, context, callback) {
var deviceFingerPrint = getDeviceFingerPrint();
user.app_metadata = user.app_metadata || {};
if (user.app_metadata.lastLoginDeviceFingerPrint !== deviceFingerPrint) {
user.app_metadata.lastLoginDeviceFingerPrint = deviceFingerPrint;
context.multifactor = {
@saltukalakus
saltukalakus / index.html
Last active July 6, 2018 17:03
Lock11 with Kerberos hosted auto login without button
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Auth0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Auth0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
@saltukalakus
saltukalakus / ws-fed-auth0.js
Created November 22, 2018 15:23 — forked from nzpcmad/ws-fed-auth0.js
Node.js with Express SSL, WS-Fed and ADFS
// http://collectivegarbage.azurewebsites.net/use-thinktecture-identity-server-v2-to-authenticate-your-node-application/
var express = require('express'),
app = express(),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
session = require('express-session'),
passport = require('passport'),
wsfedsaml2 = require('passport-wsfed-saml2').Strategy;
function (user, context, callback) {
// Set the client ID for the delegated admin extension in the below line if you wish
// and enable the if conditional
//if (context.clientID === 'DELEGATED_ADMIN_EXTENSION_CLIENT_ID') {
console.log("Insert the claim for the delegated admin extension");
const namespace = 'https://example.com/auth0-delegated-admin';
context.idToken[namespace] = { roles: [ 'Delegated Admin - Administrator' ] };
return callback(null, user, context);
//}
@saltukalakus
saltukalakus / fetch_user_profile_old_api_linkedin.js
Created January 7, 2019 14:29
Fetch User Profile Script Linkedin social old API
function(accessToken, ctx, cb) {
// call oauth2 APIwith the accesstoken and create the profile
request.get('https://api.linkedin.com/v1/people/~', {
headers: {
'Connection': 'Keep-Alive',
'Authorization': 'Bearer ' + accessToken,
'x-li-format': 'json'
},
}, function(e, r, b) {
@saltukalakus
saltukalakus / facebook.html
Created January 7, 2019 23:12
Test facebook - add your appId in FB.init - check console logs for the user profile
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
<script>
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
// The response object is returned with a status field that lets the app know the current login status of the person.
@saltukalakus
saltukalakus / workaround.html
Last active February 2, 2019 19:51
A workaround to update the username with the email during signup using JQuery for Lock widget.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Auth0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
@saltukalakus
saltukalakus / Resave-metadata.js
Created February 7, 2019 21:22
Resave metadata rule
function (user, context, callback) {
user.user_metadata = user.user_metadata || {};
user.app_metadata = user.app_metadata || {};
// persist the user_metadata and app_metadata again
auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
.then(auth0.users.updateAppMetadata(user.user_id, user.app_metadata))
.then(function(){
callback(null, user, context);
})