Skip to content

Commit d78c145

Browse files
committed
refactor: oauth2 state
1 parent 7421cab commit d78c145

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ui/src/views/login/index.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ interface qrOption {
153153
154154
const orgOptions = ref<qrOption[]>([])
155155
156+
function uuidv4() {
157+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
158+
const r = (Math.random() * 16) | 0
159+
const v = c === 'x' ? r : (r & 0x3) | 0x8
160+
return v.toString(16)
161+
})
162+
}
163+
156164
function redirectAuth(authType: string) {
157165
if (authType === 'LDAP' || authType === '') {
158166
return
@@ -191,7 +199,7 @@ function redirectAuth(authType: string) {
191199
if (authType === 'OAuth2') {
192200
url =
193201
`${config.authEndpoint}?client_id=${config.clientId}&response_type=code` +
194-
`&redirect_uri=${redirectUrl}&state=${res.data.id}`
202+
`&redirect_uri=${redirectUrl}&state=${uuidv4()}`
195203
if (config.scope) {
196204
url += `&scope=${config.scope}`
197205
}

0 commit comments

Comments
 (0)