This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uses https://www.npmjs.com/package/@thream/socketio-jwt | |
Template based on the chat example at: https://socket.io/get-started/chat | |
Run with: | |
``` | |
node index.js | |
``` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.onExecutePostLogin = async (event, api) => { | |
2 const axios = require('axios') | |
3 const namespace = 'https://example.com' | |
4 | |
5 try { | |
6 const res = await axios.get('https://api.kanye.rest/') | |
7 api.idToken.setCustomClaim(`${namespace}/quote`, res.data.quote) | |
8 } catch (e) { | |
9 console.log('Error calling the API') | |
10 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="https://cdn.auth0.com/js/auth0-spa-js/1.20/auth0-spa-js.production.js"></script> | |
<title>MFA API Test</title> | |
<style> | |
.hidden { display: none; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handler that will be called during the execution of a PostLogin flow. | |
* | |
* @param {Event} event - Details about the user and the context in which they are logging in. | |
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login. | |
*/ | |
exports.onExecutePostLogin = async (event, api) => { | |
// Craft a signed session token | |
const token = api.redirect.encodeToken({ | |
secret: 'keyboardcat', // IMPORTANT: Read this from event.secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { AuthService } from '@auth0/auth0-angular'; | |
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class AudioService { | |
isAuthenticated = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"email": "thameera@example.com", | |
"email_verified": false, | |
"custom_password_hash": { | |
"algorithm": "sha256", | |
"hash": { | |
"value": "7054f76f832d2d4e244f73b3f3f4c3702cb60a573ed12441c90f159df560fcb5", | |
"encoding": "hex" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Converts a PBKDF2 hash generated by PBKDF2PasswordEncryptor to PHC format | |
*/ | |
const digest = 'sha1' | |
const convert = origHash => { | |
const buf = Buffer.from(origHash, 'base64') | |
const keylenBits = parseInt(buf.slice(0, 4).toString('hex'), 16) | |
const keylen = keylenBits / 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AuthenticationClient = require('auth0').AuthenticationClient; | |
const prompts = require('prompts') | |
const auth0 = new AuthenticationClient({ | |
domain: 'EXAMPLE.auth0.com', | |
clientId: 'CLIENT_ID', | |
clientSecret: 'CLIENT_SECRET' | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const base32 = require('base32.js') | |
const crypto = require('crypto') | |
const secret = 'MFA_SECRET_GOES_HERE' | |
// Example secret: JRKTI3COHQ7HKOL3GBJF2MK6HBMG2S3H | |
const hotp = (counter) => { | |
const counterHex = counter.toString(16).padStart(16, '0') | |
// Calculate digest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(user, context, callback) { | |
const request = require('request'); | |
const userApiUrl = auth0.baseUrl + '/users'; | |
function updateMetadata(cb) { | |
console.log('updating'); | |
request.patch({ | |
url: userApiUrl + '/' + user.user_id, | |
headers: { |
NewerOlder