Skip to content

Instantly share code, notes, and snippets.

@nicosabena
Created December 2, 2023 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicosabena/0690c120e7d583cd299b7c1de87007c4 to your computer and use it in GitHub Desktop.
Save nicosabena/0690c120e7d583cd299b7c1de87007c4 to your computer and use it in GitHub Desktop.
Auth0 "classic" hosted login page that takes the user to a specific connection to authenticate
<!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>
<script>
// bypasses the login screen and takes the user
// directly to a specific connection to authenticate
const CONNECTION_NAME = "google-oauth2";
window.addEventListener('load', function() {
var config = JSON.parse(
decodeURIComponent(escape(window.atob('@@config@@')))
);
delete config.internalOptions.protocol;
delete config.internalOptions._intstate;
const urlParams = new URLSearchParams(
Object.assign({
client_id:config.clientID,
response_type: 'code',
redirect_uri:config.callbackURL,
connection: CONNECTION_NAME,
}, config.internalOptions)
);
const redirectUrl = `https://${config.auth0Domain}/authorize?` + urlParams.toString();
window.location = redirectUrl;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment