Skip to content

Instantly share code, notes, and snippets.

Avatar
💭

Saltuk Alakus saltukalakus

💭
View GitHub Profile
@saltukalakus
saltukalakus / update_client.md
Created Apr 19, 2022
Custom classic login page per application
View update_client.md
PATCH Auth0-domain/api/v2/clients/[client-id]
{
 "custom_login_page": " \n \n \nSign\nIn\nwith\nAuth0 \n \n \n \n
@saltukalakus
saltukalakus / RefreshTokenStepUpRule.js
Last active Jan 5, 2022
Step up authentication with refresh tokens.
View RefreshTokenStepUpRule.js
function (user, context, callback) {
// Only applied for the refresh token flow along with the special scope (e.g.: transfer:funds) that
// will trigger the MFA step up.
if (context.protocol === "oauth2-refresh-token" &&
context.request.body &&
context.request.body.scope &&
context.request.body.scope.indexOf('transfer:funds') > -1) {
// Insert a custom claim in id token which would be checked along with amr claim
View profileMapper.js
module.exports = function (raw_data) {
var profile = {
id: raw_data.objectGUID || raw_data.uid || raw_data.cn,
displayName: raw_data.displayName,
name: {
familyName: raw_data.sn,
givenName: raw_data.givenName
},
nickname: raw_data['sAMAccountName'] || raw_data['cn'] || raw_data['commonName'],
groups: raw_data['groups'],
View default-custom-hosted-page.html
<!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">
</head>
<style>
@saltukalakus
saltukalakus / classic-hosted-page.html
Last active Mar 29, 2021
The passwordless and regular login with lock on the same universal page.
View classic-hosted-page.html
<!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">
</head>
<style>
@saltukalakus
saltukalakus / rule.js
Created Mar 25, 2021
Prevents users from logging in if email isn't shared in their Facebook account.
View rule.js
function (user, context, callback) {
if (context.connection === "facebook" && !user.email) {
return callback(new UnauthorizedError("We can't access your email. Please enable sharing your e-mail from Facebook apps settings and re-try."));
}
return callback(null, user, context);
}
@saltukalakus
saltukalakus / m2m_action.js
Created Mar 16, 2021
Sample Auth0 action to execute on a specific API and Application for adding a custom claim.
View m2m_action.js
/** @type {CredentialsExchangeAction} */
module.exports = async (event, context) => {
// This action works for an API with the API audience https://example.com/api along with an application with the
// client id 5drbxrf5qMc1KTFNEw6Wjrbw319pOiyW
if (event.audience === "https://example.com/api" && event.client.id === "5drbxrf5qMc1KTFNEw6Wjrbw319pOiyW") {
return {
customClaims: {
"https://www.customnamespace.com/some_key": "some value"
}
};
@saltukalakus
saltukalakus / sample.java
Created Feb 9, 2021
Java sample to reset connections every 30 seconds
View sample.java
object PoolingHttpClientFactory {
private val poolingConnectionManager = PoolingHttpClientConnectionManager().apply {
maxTotal = 40
defaultMaxPerRoute = 40
}
// called every 30 seconds from a scheduled task
fun cleanupConnections() {
@saltukalakus
saltukalakus / rule.js
Created Jan 26, 2021
Multiple attributes to a single attribute in SAML response when Auth0 is the SAML IdP
View rule.js
function (user, context, callback) {
// Execute the rule only for the required Apps's client ID
var samlIdpClientId = 'LYkMiVolEzhDzaTQJPg6mRI468blVFU4';
if (context.clientID !== samlIdpClientId) {
return callback(null, user, context);
}
user.tmpMemberOf = "";
function appendMember(memberOf) {
@saltukalakus
saltukalakus / account_link_extension_rule_sample.js
Created Jan 23, 2021
Account linking extension rule sample
View account_link_extension_rule_sample.js