Skip to content

Instantly share code, notes, and snippets.

@jeff-auth0
jeff-auth0 / login.js
Last active March 24, 2023 03:50
Trickle user migration to Auth0 from Azure B2C AD
/**
*
* NOTE: THIS SCRIPT IS A GUIDE ONLY AND IT IS NOT TESTED IN A PRODUCTION ENVIRONMENT
*
* HOW:
* 1. Azure ROPC (Resource Owner Password Credentials) flow will be used to migrate users from Azure B2C AD to Auth0.
* 2. Lazy migration needs to be enable on your Auth0 Database. https://auth0.com/docs/manage-users/user-migration/configure-automatic-migration-from-your-database
*
*
* References:
function requireMfa(user, context, callback) {
// Context object Ref: https://auth0.com/docs/customize/rules/context-object
// It only makes sense to prompt for MFA when the user has at least one
// enrolled MFA factor.
const enforceMfaForOrgs = ['id_org1', 'id_org2'];
const shouldPromptMfa = context.organization && context.organization.id && enforceMfaForOrgs.indexOf(context.organization.id) >= 0;
const userEnrolledFactors = user.multifactor || [];
const canPromptMfa = userEnrolledFactors.length > 0;
@jeff-auth0
jeff-auth0 / login.js
Last active November 24, 2022 05:59
This login script will be used to generate auth0 tokens in return of AAD id_token generated for user logged in to their Windows 10 devices.
/*
*
* Purpose of this script:
* This login script will be used to generate auth0 tokens in return of AAD id_token generated
* for user logged in to their Windows 10 devices.
*
* Why:
* This is similar to native SIWA, that a desktop windows application performs API based request to OS
* to authenticate current user, user sees a consent page, and after consent, application receives
* id_token of current user’s Azure AD account associated with Windows 11 machine.
@startuml
title <size:50> Title of your diagram
skinparam sequence {
ArrowColor DeepSkyBlue
ActorBorderColor DeepSkyBlue
LifeLineBorderColor blue
LifeLineBackgroundColor #A9DCDF
ParticipantBorderColor DeepSkyBlue
@jeff-auth0
jeff-auth0 / test_users.tf
Last active October 22, 2022 00:12
Create test users in Auth0 tenant
terraform {
required_providers {
auth0 = {
source = "auth0/auth0"
version = "0.39.0"
}
}
}
provider "auth0" {