Skip to content

Commit 20a3719

Browse files
Geczyluisrudge
authored andcommitted
fix silent auth: messages not from auth0 iframe (#44)
* fix silent auth: messages not from auth0 iframe
1 parent ea21700 commit 20a3719

2 files changed

Lines changed: 7 additions & 20 deletions

File tree

05-Token-Renewal/silent.html

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,11 @@
44
<meta charset="utf-8">
55
<script src="https://cdn.auth0.com/js/auth0/8.8/auth0.min.js"></script>
66
<script>
7-
var AUTH0_CLIENT_ID = '{CLIENT_ID}';
8-
var AUTH0_DOMAIN = '{DOMAIN}';
9-
10-
if (!AUTH0_CLIENT_ID || !AUTH0_DOMAIN) {
11-
alert('Make sure to set the AUTH0_CLIENT_ID and AUTH0_DOMAIN variables in silent.html.');
12-
}
13-
14-
var webAuth = new auth0.WebAuth({
15-
domain: AUTH0_DOMAIN,
16-
clientID: AUTH0_CLIENT_ID,
17-
scope: 'openid profile',
18-
responseType: 'token id_token',
19-
redirectUri: 'http://localhost:3000'
20-
});
21-
</script>
22-
<script>
23-
webAuth.parseHash(window.location.hash, function (err, response) {
24-
parent.postMessage(err || response, 'http://localhost:3000');
25-
});
7+
parent.postMessage({
8+
hash: window.location.hash,
9+
type: 'auth0:silent-authentication'
10+
}, "http://localhost:3000/");
11+
};
2612
</script>
2713
</head>
2814
<body></body>

05-Token-Renewal/src/Auth/Auth.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export default class Auth {
101101
{
102102
audience: AUTH_CONFIG.apiUrl,
103103
redirectUri: AUTH_CONFIG.silentAuthRedirect,
104-
usePostMessage: true
104+
usePostMessage: true,
105+
postMessageDataType: 'auth0:silent-authentication',
105106
},
106107
(err, result) => {
107108
if (err) {

0 commit comments

Comments
 (0)