Skip to content

Instantly share code, notes, and snippets.

@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.
@thameera
thameera / action.js
Last active February 3, 2024 00:42
Actions redirect example
/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
// Craft a signed session token
const token = api.redirect.encodeToken({
secret: 'keyboardcat', // IMPORTANT: Read this from event.secrets
@ggoodman
ggoodman / README.md
Created February 25, 2021 15:14
Using the concept of defer from golang to simplify resource cleanup in Javascript

The withCleanup helper

Example

const result = await withCleanup(async (defer) => {
  const fileHandle = await getFileHandle();
  defer(() => fileHandle.close());
   
 // Carry on
async function getTokenFromRulesConfig(user, context, callback) {
const m2mClientID = configuration.m2mCID;
const m2mClientSecret = configuration.m2mCSecret;
let auth0Domain = '<<your_tenant>>.auth0.com';
const moment = require('moment-timezone');
let axios = require('axios');
const country = context.request.geoip.country_name;
const data = {
user_app_metadata: user.app_metadata,
email: user.email,
@pravinady
pravinady / detect-login
Last active April 6, 2020 23:28
detect-login
function (user, context, callback) {
//Check if authn method match pwd or social connections
const authMethod = context.authentication.methods.find(
(method) => {
return (method.name === 'pwd' || method.name === 'federated');
}
);
console.log('auth method is:', authMethod);
@zamd
zamd / landing_page.md
Last active January 26, 2019 01:05
Selecting landing page via Auth0

Auth0 offers passing extra whitelisted params to upstream IdPs. This feature can be used to pass initial screen/page hint to the upstream IdP.

  • PATCH the custom oauth connection to whitelist and alias the upstream param
curl -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlFqVTVRVEpEUmpnd09UUXpOVGxFUlVZeFJURTRNams0TVRFMlFUUkVNVGxGTlRsRE5VWXlRUSJ9." -X PATCH  -H "Content-Type: application/json" -d '{"options":{"upstream_params":{"initial_page":{"alias":"login_hint"}}}}' "https://{domain}.auth0.com/api/v2/connections/{id}"
  • You can now pass intial page as standard login_hint value and auth0 would translate this to the configured outgoing parameter.
@pat
pat / LICENSE.txt
Last active February 4, 2023 21:02
Running Setup SQL scripts on an RDS instance within a VPC, via Terraform
The MIT License (MIT)
Copyright (c) 2018 Pat Allan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: