Skip to content

Instantly share code, notes, and snippets.

@abbaspour
abbaspour / rule1.js
Last active July 21, 2022 05:15
Auth0 Rules Caching Logger
function boostrapRule(user, context, callback) {
/**
* Create a new Logger instance
*
* @returns {{log: (function(*=): number), commitLogs: (function(): void)}}
*/
const loggerFactory = () => {
const logs = [];
const commitLogs = () => {
if (logs.length === 0)
@abbaspour
abbaspour / curl-multipart-gz.sh
Created April 17, 2022 21:12
Compressed Multipart Form Data POST with CURL
#!/usr/bin/env bash
set -eufo pipefail
declare -A form_parts
function usage() {
cat <<END >&2
USAGE: $0 [-F key=value] [-F key=@file] [curl-opts] [-v|-h]
-F key=value # curl post key=value
@abbaspour
abbaspour / ul.html
Created October 28, 2021 00:01
redirect from UL to specific connection
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.jsdelivr.net/lodash/4.17.4/lodash.core.min.js"></script>
<script src="//cdn.auth0.com/js/auth0/8.12.2/auth0.min.js"></script>
</head>
<body>
<script>
// standard config decoding as in the default template
var config = JSON.parse(decodeURIComponent(escape(window.atob('@@config@@'))));
@abbaspour
abbaspour / client.conf
Last active December 17, 2023 22:53
https with stunnel and socat
client = yes
debug = 5
foreground = yes
pid = /var/tmp/stunnel-client.pid
cert= st.pem
[Application]
accept = 1081
connect = 3000
@abbaspour
abbaspour / post-change-password-hook-auth-api.js
Last active March 14, 2022 21:49
Auth0 Change Password Hook to Revoke (Rotating) Refresh Tokens
module.exports = function (user, context, cb) {
const ManagementClient = require("auth0@2.23.0").ManagementClient;
const auth0 = new ManagementClient({
domain: context.connection.tenant + '.eu.auth0.com',
clientId: context.webtask.secrets.delete_refresh_token_client_id,
clientSecret: context.webtask.secrets.delete_refresh_token_client_secret,
scope: 'read:device_credentials delete:device_credentials'
});
const getRefreshTokens = type => auth0.deviceCredentials.getAll({ user_id: user.id, type: type });
const deleteRefreshToken = id => auth0.deviceCredentials.delete({ id: id })
@abbaspour
abbaspour / nginx.conf
Last active February 4, 2024 19:20
Guide how to enable JWT validation on open source nginx server using ngx-http-auth-jwt-module
daemon off;
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
@abbaspour
abbaspour / main.dart
Created May 19, 2020 04:48
Flutter App Auth + Auth0
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:flutter_appauth/flutter_appauth.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
@abbaspour
abbaspour / co-wm.html
Created April 3, 2020 21:50
Auth0 Credentials Login with Session
<!doctype html>
<html lang="en">
<head>
<title>Cross Origin + Silent Authentication</title>
<meta charset="utf-8">
<script src="https://cdn.auth0.com/js/auth0/9.13.1/auth0.min.js"></script>
</head>
<body>
<label for="username">Username</label><input id="username" type="text"/>
<br/>
@abbaspour
abbaspour / ropg.html
Last active April 2, 2020 02:17
Auth0 ROPG from Browser with Google reCAPTCHA v3
<!doctype html>
<html lang="en">
<head>
<title>ROPG</title>
<meta charset="utf-8">
<script src="https://www.google.com/recaptcha/api.js?render=XXXXXX"></script>
<style>
.grecaptcha-badge { visibility: hidden; }
</style>
</head>
@abbaspour
abbaspour / dl-wistia.sh
Last active August 1, 2019 05:51
download videos from wistia.com
#!/bin/bash
set -euo pipefail
[[ "$#" -lt 1 ]] && { echo "$0 http://someurl" && exit 1; }
which curl >/dev/null || { echo >&2 "Error: you need curl"; exit 2; }
which jq >/dev/null || { echo >&2 "Error: you need jq"; exit 2; }
which awk >/dev/null || { echo >&2 "Error: you need awk"; exit 2; }