Skip to content

Commit afce130

Browse files
committed
feat: state using crypto
1 parent 0ef9aec commit afce130

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

web/components/SsoButton.ce.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ const getStateToken = (): string | null => {
4949
};
5050
5151
const generateStateToken = (): string => {
52-
const state =
53-
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
52+
const array = new Uint8Array(32);
53+
window.crypto.getRandomValues(array);
54+
const state = Array.from(array, byte => byte.toString(16).padStart(2, '0')).join('');
5455
sessionStorage.setItem('sso_state', state);
5556
return state;
5657
};

0 commit comments

Comments
 (0)