Skip to content

Instantly share code, notes, and snippets.

View dcaponi's full-sized avatar

Dominick Caponi dcaponi

View GitHub Profile
@dcaponi
dcaponi / app.json
Last active May 4, 2020 14:53
apps example
{
"updated_at": "2020-05-02T16:17:18Z",
"auth_method": 0,
"icon_url": "https://cdn.something.net/images/icons/square/5558229540474713/my_icon.png?1427294311",
"connector_id": 20938,
"role_ids": [],
"id": 1023060,
"name": "fit bit company portal",
"created_at": "2020-05-02T16:17:18Z",
"notes": "",
@dcaponi
dcaponi / main.tf
Last active May 4, 2020 14:53
example hcl
provider "onelogin" {
client_id = "xxxxxxxxxxxxxxxxxxxx"
client_secret = "xxxxxxxxxxxxxxxxxxxx"
url = "https://api.us.onelogin.com"
}
resource "onelogin_saml_apps" "aws-sample-1"{
connector_id = 50534
name = "AWS Multi Role - Terraform change"
description = "AWS Multi Role app created via Terraform"
@dcaponi
dcaponi / remove_tags.bash
Created May 15, 2020 18:27
Reset all tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d
@dcaponi
dcaponi / linux_commands.md
Created May 15, 2020 18:28
Linux Commands

#Linux Commands

Simple Stuff

grep - search for a string

search for word "stuff" in a file called filename and returns all lines with the word "stuff"

grep "stuff" filename.ext

@dcaponi
dcaponi / release.yml
Created June 7, 2020 21:34
Multi-Platform Go Ship with GH Action
on:
push:
tags:
- '*'
name: Release
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
@dcaponi
dcaponi / ship.sh
Created June 7, 2020 21:35
Builds go binaries, adds some literature, and compresses the folder for Mac, Linux, and Windows
#!/usr/bin/env bash
package=$1
if [[ -z "$package" ]]; then
echo "usage: $0 <package-name>"
exit 1
fi
package_split=(${package//\// })
package_name=${package_split[${#package_split[@]}-1]}
@dcaponi
dcaponi / pkce_code_challenge.js
Created January 1, 2021 19:55
Takes a code_verifier string and makes a legal code_challenge out of it
const createCodeChallenge = ( codeVerifier ) => {
if ( typeof window !== 'undefined' && !!( window.crypto ) && !!( window.crypto.subtle ) ) {
return new Promise( ( resolve, reject ) => {
let codeVerifierCharCodes = textEncodeLite( codeVerifier );
crypto.subtle
.digest( 'SHA-256', codeVerifierCharCodes )
.then(
hashedCharCodes => resolve( urlSafe( new Uint8Array(hashedCharCodes) ) ),
error => reject( error )
);
@dcaponi
dcaponi / code_verifier.js
Created January 1, 2021 19:56
Creates a legal code_verifier based on the OAuth Spec
const createCodeVerifier = ( size ) => {
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~';
const charsetIndexBuffer = new Uint8Array( size );
for ( let i = 0; i < size; i += 1 ) {
charsetIndexBuffer[i] = ( Math.random() * charset.length ) | 0;
}
let randomChars = [];
for ( let i = 0; i < charsetIndexBuffer.byteLength; i += 1 ) {
@dcaponi
dcaponi / pkce_first_step.js
Created January 1, 2021 19:56
Builts the auth url to an IdP using PKCE flow
const PKCEAuthCodeFirstStep = () => {
let oidcURL = `${process.env.OIDC_IDP_URL}/auth`;
let queryParams = [`client_id=${process.env.OIDC_CLIENT_ID}`];
let codeVerifier = createCodeVerifier( 50 );
localStorage.setItem( 'code_verifier', codeVerifier );
return createCodeChallenge( codeVerifier ).then( codeChallenge => {
queryParams.push(`code_challenge=${codeChallenge}`);
queryParams.push(`redirect_uri=http://localhost/login_oidc`);
queryParams.push(`code_challenge_method=S256`);
@dcaponi
dcaponi / pkce_token_step.js
Created January 1, 2021 20:09
second step in pkce flow to get an access token from our auth code
const PKCEAuthCodeSecondStep = ( code ) => {
let oidcURL = `${process.env.OIDC_IDP_URL}/token`;
let params = qs.stringify( {
grant_type: "authorization_code",
redirect_uri: "http://localhost/login_oidc",
client_id: process.env.OIDC_CLIENT_ID,
code_verifier: localStorage.getItem( 'code_verifier' ),
code
} );