Added nonce value generator

This commit is contained in:
Martin 2021-03-24 18:17:05 +01:00
parent 4c0e7406f5
commit 7f4e260532

View File

@ -49,10 +49,19 @@ export class LoginComponent implements OnInit {
'&prompt=consent' +
'&redirect_uri=http://localhost:4200' +
'&scope=openid%20profile' +
'&nonce=abcdef';
'&nonce=' + this.randomString(20);
window.location.replace(url);
}
randomString(length: number) {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
logout() {
const url = this.openid_endpoint + '/logout' +
'?id_token_hint=' + this.id_token + '&' +