Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Cunningham joshcanhelp

View GitHub Profile
@joshcanhelp
joshcanhelp / checkWordPressForUser.js
Last active Dec 31, 2020
Check a WordPress migration endpoint for the existence of a user.
View checkWordPressForUser.js
async function checkWordPressForUser(user, context, callback) {
if (!user.email) {
console.log("User does not have an email to use.");
return callback(null, user, context);
}
const customClaimNamespace = "https://custom-claim/has_wp_account";
const {
WP_API_CLIENT_ID,
WP_API_IDENTIFIER,
@joshcanhelp
joshcanhelp / .bashrc
Last active Jan 8, 2021
Easy ULP modification with Netlify
View .bashrc
# ...
export AUTH0_API2_TOKEN="Your management API token goes here"
export AUTH0_API2_DOMAIN="Your tenant domain goes here"
# https://cli.netlify.com/
alias sync_ulp='netlify deploy --prod --dir . && curl --request PUT \
--data "@./index.html" \
--header "authorization: Bearer $AUTH0_API2_TOKEN" \
--url "https://$AUTH0_API2_DOMAIN/api/v2/branding/templates/universal-login" \
View delete_unused_files.sh
while IFS= read -r -d '' file
do
if grep -qr "$file" ../content/md
then echo "Keeping $file";
else rm "$file";
fi
done < <(find _images -type f -print0)
@joshcanhelp
joshcanhelp / wp-auth0-callback.php
Created Nov 1, 2019
Add another callback URL to the WP-Auth0 plugin
View wp-auth0-callback.php
<?php
function namespace_add_auth0_callback_rewrite() {
add_rewrite_rule('^auth0/callback$', 'index.php?auth0=1', 'top');
}
add_action('init', 'namespace_add_auth0_callback_rewrite');
function namespace_add_auth0_callback_param( $params ) {
$params['redirect_uri'] = home_url( '/auth0/callback' );
return $params;
}
@joshcanhelp
joshcanhelp / wp-auth0-callback.php
Created Nov 1, 2019
Add another callback URL to the WP-Auth0 plugin
View wp-auth0-callback.php
<?php
function namespace_add_auth0_callback_rewrite() {
add_rewrite_rule('^auth0/callback$', 'index.php?auth0=1', 'top');
}
add_action('init', 'namespace_add_auth0_callback_rewrite');
function namespace_add_auth0_callback_param( $params ) {
$params['redirect_uri'] = home_url( '/auth0/callback' );
return $params;
}
@joshcanhelp
joshcanhelp / SetAccessTokenCookie.php
Last active Feb 6, 2019
Auth callback middleware to set an access token in Laravel
View SetAccessTokenCookie.php
<?php
// app/Http/Middleware/SetAccessTokenCookie.php
namespace App\Http\Middleware;
use Closure;
class SetAccessTokenCookie
{
/**
@joshcanhelp
joshcanhelp / laravel-auth0.php
Last active Jan 29, 2019
Laravel config settings for Auth0 API authentication
View laravel-auth0.php
<?php
// config/laravel-auth0.php
return [
// ...
// Your Auth0 domain as a URL with a trailing slash.
'authorized_issuers' => [ 'https://your-tenant.auth0.com/' ],
// The "Identifier" field for the API you created in Auth0.
'api_identifier' => 'https://quickstarts/api',
// This is the same as the API algorithm.
'supported_algs' => [ 'RS256' ],
@joshcanhelp
joshcanhelp / CheckJWT.php
Last active Jan 29, 2019
Laravel middleware for access token verification on an API
View CheckJWT.php
<?php
// app/Http/Middleware/CheckJWT.php
namespace App\Http\Middleware;
use Closure;
use Auth0\SDK\JWTVerifier;
class CheckJWT {
public function handle($request, Closure $next) {
@joshcanhelp
joshcanhelp / sdk_quality_scripts.js
Last active Feb 11, 2020
Google Script Editor functions for getting SDK quality metrics
View sdk_quality_scripts.js
/* globals SpreadsheetApp, Browser, CacheService, UrlFetchApp, PropertiesService */
/*
*
* Macro functions
*
*/
/**
* Prompt the user for a GitHub API token.
View Sample DB login script
function login (email, password, callback) {
console.log(email);
var request = require("request");
request.post(
"[APP_ENDPOINT_HERE]",
{
form: {