Skip to content

Instantly share code, notes, and snippets.

function (user, context, callback) {
    console.log("executing rule ");
    if (context.clientID === 'ULw7vqL2WK41DIwc2r4QxP78bISpQ2pN') {
       console.log("Adding claim rule ");
        const namespace = 'https://example.com/auth0-delegated-admin';
        context.idToken[namespace] = {
            roles: (context.authorization || {}).roles
        };
 }
@Tanver-Hasan
Tanver-Hasan / rule.md
Last active September 28, 2021 10:02
User AllowList
function userWhitelist(user, context, callback) {

    // Skipping rule execution if clientId and connection does not match
    if (context.clientID !== '[Client ID]' && context.connection !== '[Connection Name]'){
        return callback(null,user,context);
    }

    // Access should only be granted to verified users.
 if (!user.email || !user.email_verified) {
@Tanver-Hasan
Tanver-Hasan / hostedLoginPage.html
Created November 25, 2021 21:09
Auth0 Custom Login Form template (username/password, social, passwordless sms)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Auth0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js"></script>
@Tanver-Hasan
Tanver-Hasan / CustomDB-ROPG.md
Last active August 25, 2022 16:30
Executing ROPG grant type in custom db to authenticate the user with another tenant

Custom DB script for connecting with root teant which stores the user information. The login script uses authentication api and exeucte ROPG. get_user script uses apiv2 to query and return the user information

@Tanver-Hasan
Tanver-Hasan / Vagrantfile
Created February 15, 2022 22:27
Vagrant file for provisiong Centos:7 machine with Genome, Docker engine , selinux
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.provision :docker
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "2048"
vb.cpus = 2
@Tanver-Hasan
Tanver-Hasan / custom-param.md
Created March 15, 2022 12:42
Pass custom parameter in /authorize endpoint

For auth0-spa-js and auth0-react - any extra options you pass to the SDK will be sent as custom params to the authorization server when redirecting to /authorize endpoint, eg

auth0-spa-js SDK

const auth0 = await createAuth0Client({
  domain: '<AUTH0_DOMAIN>',
  client_id: '<AUTH0_CLIENT_ID>',
  redirect_uri: '<MY_CALLBACK_URL>',
  // Pass custom parameters to login & silent auth
 customParam="foo"
// Exported user profile
{
"created_at": "2019-09-13T10:31:27.130Z",
"email": "[email protected]",
"email_verified": false,
"identities": [
{
"profileData": {
function (user, context, callback) {
const BANKID = 'SwedishBankID!NorwegianBankID!SuomiFi';
if (context.protocol === "redirect-callback") {
return callback(null, user, context);
}
if (!BANKID.includes(context.connection) ) {
return callback(null, user, context);
}
curl --location --request PUT 'https://[Auth0 Domain]/api/v2/prompts/login/custom-text/en' \
--header 'Authorization: Bearer {Management API token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"login": {
"usernamePlaceholder": "Enter username or email address",
"passwordPlaceholder":"Enter password"
}
}'
@Tanver-Hasan
Tanver-Hasan / script.js
Created November 2, 2023 17:31
Slipt auth0 cli terraform generated file into files by resource catagory
const fs = require('fs');
const path = require('path');
// This function reads the main.tf file and splits it into sections based on resources
function splitTerraformFile(filePath) {
const content = fs.readFileSync(filePath, 'utf-8');
// Matches all resource blocks
const resourceRegex = /resource\s+"([^"]+)"\s+"([^"]+)"\s+\{[\s\S]+?\n\}/g;
let match;