Skip to content

Instantly share code, notes, and snippets.

@Tanver-Hasan
Tanver-Hasan / Auth0 Organization demo.md
Last active January 18, 2024 15:29
Organization Demo

Authorization Prompt

https://tanver-custom.eu.auth0.com/authorize?
client_id=T4T3wsZFW1zXj0cSSSJtOKG2bvToS3Pd&
response_type=code&scope=openid+email&
redirect_uri=http://localhost:3000&state=12345&nonce=223
URL='https://tanver-custom.eu.auth0.com/api/v2/prompts/signup/partials'
TOKEN='Management API Token'
curl -X PUT \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $TOKEN" \
-d '{"signup": {"form-content-start":"<div class=\"ulp-field\">\n <label for=\"first-name\">First Name</label>\n <input type=\"text\" name=\"ulp-first-name\" id=\"first-name\">\n</div> \n <div class=\"ulp-field\">\n <label for=\"last-name\">Last Name</label>\n <input type=\"text\" name=\"ulp-last-name\" id=\"last-name\">\n </div>","form-content-end":"<div class=\"ulp-field\"> \n<label for=\"confirm-password\">Confirm Password</label> \n <input type=\"text\" name=\"ulp-confirm-password\" id=\"confirm-password\"> \n<div class=\"ulp-error-info\"> \n Confirm Password is required</div> \n</div> \n <div class=\"ulp-field\"> \n <input type=\"checkbox\" name=\"ulp-terms-of-service\" id=\"terms-of-service\">\n <label for=\"terms-of-service\">\n I want to receive marketting information <a href=\"#\">Terms of Service</a>\n</label>
@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;
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"
}
}'
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);
}
// Exported user profile
{
"created_at": "2019-09-13T10:31:27.130Z",
"email": "b00316640888888@gmail.com",
"email_verified": false,
"identities": [
{
"profileData": {
@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"
@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 / 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 / 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>