Skip to content

Instantly share code, notes, and snippets.

View arcseldon's full-sized avatar

Richard Seldon arcseldon

View GitHub Profile
@arcseldon
arcseldon / free-er.js
Created February 28, 2016 06:29 — forked from DrBoolean/free-er.js
Free(er) monads in JS (pt 1)
const daggy = require('daggy')
const compose = (f, g) => x => f(g(x))
const id = x => x
const kleisli_comp = (f, g) => x => f(x).chain(g)
//=============FREE=============
const Free = daggy.taggedSum({Impure: ['x', 'f'], Pure: ['x']})
const {Impure, Pure} = Free
@arcseldon
arcseldon / free-er2.js
Created February 28, 2016 06:29 — forked from DrBoolean/free-er2.js
Free(er) Monads Pt2
const daggy = require('daggy')
const Task = require('data.task')
const _ = require('lodash')
const kleisli_comp = (f, g) => x => f(x).chain(g)
const compose = (f, g) => x => f(g(x))
const id = x => x
//=============FREE=============
const Free = daggy.taggedSum({Impure: ['x', 'f'], Pure: ['x']})
const {Impure, Pure} = Free
@arcseldon
arcseldon / Auth0JWTSigner.scala
Created March 5, 2016 07:53
Provides a blueprint for how to create an Auth0 JSON Web Token (JWT)
// richard.seldon@auth0.com
// commons-codec-1.10.jar
// java-jwt-2.1.0.jar
// see docs here: https://auth0.com/docs/jwt
import java.security.SignatureException
import java.text.SimpleDateFormat
@arcseldon
arcseldon / noLoginForConnectionType.js
Created March 15, 2016 08:28
Auth0 Rule sample - checking for connection type and login count.
function noLoginForConnectionType(user, context, callback) {
user.app_metadata = user.app_metadata || {};
console.log('connection: ' + context.connection);
if (context.connection === 'google-oauth2'){
var cnt = context.stats.loginsCount;
console.log('user login count: ' + cnt);
if (cnt <= 1) {
console.log('Setting loginDisabled');
user.app_metadata.loginDisabled = true;
auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
@arcseldon
arcseldon / .eslintrc
Created April 29, 2016 14:57 — forked from hendrikswan/.eslintrc
Packages and build config for Build Cross Platform React Native Apps with Exponent and Redux
{
"extends": "airbnb/base",
"plugins": [
"react"
],
"env": {
"node": true,
"jasmine": true,
},
"rules": {

Own version of com.auth0.SessionUtils with the following two methods overridden in custom impl.

     import org.springframework.beans.BeanUtils;
     ...
     
     
     public static Auth0User getAuth0User(final HttpServletRequest req) {
        System.out.println("GET AUTH0 USER");
        final MyAuth0User myAuth0User = (MyAuth0User) getSession(req).getAttribute(AUTH0_USER);
@arcseldon
arcseldon / Option1.js
Created November 8, 2016 00:39 — forked from pushpabrol/Option1.js
How to use ldapjs within a custom database connection in Auth0
function login(email, password, callback) {
var ldap = require('ldapjs');
if (!global.ldapClient) {
// console.log('Global Client not found');
var client = ldap.createClient({
url: 'ldap://server:389',
idleTimeout: 30000
});
client.bind('uid=admin,ou=system', 'secret', function(err) {
import _ from 'lodash';
import fetch from 'node-fetch';
import delay from 'delay';
export async function pingServers(servers) {
let failedServers = {};
for (const url of servers) {
let failures = 0;
for (const i of _.range(3)) {
const response = await fetch(url);
@arcseldon
arcseldon / contest-webtask.js
Created November 20, 2016 07:24 — forked from woloski/contest-webtask.js
Contest Signup Webtask
'use latest';
import express from 'express';
import { fromExpress } from 'webtask-tools';
import bodyParser from 'body-parser';
const app = express();
var jwt = require('express-jwt');
var jwtCheck = jwt({
@arcseldon
arcseldon / getUser.js
Last active November 26, 2016 22:06
auth0 get users endpoint invocation server side (trusted server)
function getManagementApiToken() {
const cachedToken = cache.get('managementApi');
if (cachedToken) {
return Promise.resolve(cachedToken);
} else {
return request.post({
url: `https://${process.env.AUTH0_DOMAIN}/oauth/token`,
body: {
client_id: process.env.CLIENT_ID,
client_secret: process.env.CLIENT_SECRET,