Skip to content

Instantly share code, notes, and snippets.

View saltukalakus's full-sized avatar
💭

Saltuk Alakus saltukalakus

💭
View GitHub Profile
@saltukalakus
saltukalakus / RefreshTokenStepUpRule.js
Last active January 5, 2022 19:14
Step up authentication with refresh tokens.
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
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'],
<!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 March 29, 2021 10:25
The passwordless and regular login with lock on the same universal page.
<!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 March 25, 2021 16:25
Prevents users from logging in if email isn't shared in their Facebook account.
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 March 16, 2021 16:56
Sample Auth0 action to execute on a specific API and Application for adding a custom claim.
/** @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 February 9, 2021 12:59
Java sample to reset connections every 30 seconds
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 January 26, 2021 10:27
Multiple attributes to a single attribute in SAML response when Auth0 is the SAML IdP
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 January 23, 2021 13:54
Account linking extension rule sample
@saltukalakus
saltukalakus / tls_troubleshoot.sh
Created January 21, 2021 10:15
TLS troubleshoot
# Check if a custom domain supports TLS 1_x
openssl s_client -connect saltukalakus-cd-27cmr6vn4orkxckx.edge.tenants.auth0.com:443 -servername demo.saltukalakus.com -tls1_1
openssl s_client -connect saltukalakus-cd-27cmr6vn4orkxckx.edge.tenants.auth0.com:443 -servername demo.saltukalakus.com -tls1_2