Skip to content

Instantly share code, notes, and snippets.

@saltukalakus
Last active June 2, 2025 20:38
Show Gist options
  • Save saltukalakus/7a4063b06119e66c82cefb0d58e2b8ad to your computer and use it in GitHub Desktop.
Save saltukalakus/7a4063b06119e66c82cefb0d58e2b8ad to your computer and use it in GitHub Desktop.
Lock11 with Kerberos hosted auto login without button
<!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" />
</head>
<body>
<!--[if IE 8]>
<script src="//cdnjs.cloudflare.com/ajax/libs/ie8/0.2.5/ie8.js"></script>
<![endif]-->
<!--[if lte IE 9]>
<script src="https://cdn.auth0.com/js/base64.js"></script>
<script src="https://cdn.auth0.com/js/es5-shim.min.js"></script>
<![endif]-->
<script src="https://cdn.auth0.com/js/auth0/9.6/auth0.min.js"></script>
<script src="https://cdn.auth0.com/js/lock/11.7/lock.min.js"></script>
<script>
// Decode utf8 characters properly
var config = JSON.parse(decodeURIComponent(escape(window.atob('@@config@@'))));
config.extraParams = config.extraParams || {};
var connection = config.connection;
var prompt = config.prompt;
var languageDictionary;
var language;
if (config.dict && config.dict.signin && config.dict.signin.title) {
languageDictionary = { title: config.dict.signin.title };
} else if (typeof config.dict === 'string') {
language = config.dict;
}
var loginHint = config.extraParams.login_hint;
/*
* Helper to get a querystring value.
*/
function getParameterByName( name ){
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
function runLock() {
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
configurationBaseUrl: 'https://cdn.auth0.com/',
auth: {
sso:true,
redirectUrl: config.callbackURL,
responseType: (config.internalOptions || {}).response_type ||
config.callbackOnLocationHash ? 'token' : 'code',
params: config.internalOptions
},
assetsUrl: config.assetsUrl,
allowedConnections: connection ? [connection] : null,
rememberLastLogin: true,
language: language,
languageDictionary: languageDictionary,
theme: {
//logo: 'YOUR LOGO HERE',
//primaryColor: 'green'
},
prefill: loginHint ? { email: loginHint, username: loginHint } : null,
closable: false,
// uncomment if you want small buttons for social providers
// socialButtonStyle: 'small'
});
lock.show();
}
var params = Object.assign({
domain: config.auth0Domain,
clientID: config.clientID,
redirectUri: config.callbackURL,
responseType: 'code'
}, config.internalOptions);
var webAuth = new auth0.WebAuth(params);
webAuth.client.getSSOData(true, function(err, data) {
if (!err) {
if (data.connection && data.strategy === 'ad') {
webAuth.authorize({
connection: data.connection,
state: getParameterByName('state'),
protocol: getParameterByName('protocol') || 'oauth2',
scope: getParameterByName('scope') || 'openid'
});
} else {
runLock()
}
} else {
runLock();
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment