Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Support KeyCloak (OpenID) (#1914)
Browse files Browse the repository at this point in the history
  • Loading branch information
elsiosanchez authored Feb 14, 2024
1 parent c8cd67e commit ec39167
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
3 changes: 0 additions & 3 deletions src/api/ADempiere/security/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ export function loginAuthentication({
state_parameter: state
}
})
.then(response => {
return response
})
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/icons/svg/keycloak.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ const actions = {
code,
state
})
.then(token => {
.then(response => {
const { token } = response
commit('SET_TOKEN', token)
setToken(token)
resolve()
resolve(token)
})
.catch(error => {
reject(error)
Expand Down
37 changes: 23 additions & 14 deletions src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -296,26 +296,27 @@ export default {
return redirect[3]
},
svgService(openId) {
const { authorization_uri } = openId
const searchInclude = authorization_uri.replace('https://', '')
const index = searchInclude.search('.com/')
let svg
const { display_name } = openId
let svg = ''
switch (true) {
case searchInclude.slice(0, index).includes('microsoftonline'):
case display_name.includes('microsoftonline'):
svg = 'microsoft'
break
case searchInclude.slice(0, index).includes('google'):
case display_name.includes('google'):
svg = 'google-gmail'
break
case searchInclude.slice(0, index).includes('github'):
case display_name.includes('github'):
svg = 'github'
break
case searchInclude.slice(0, index).includes('gitlab'):
case display_name.includes('gitlab'):
svg = 'gitlab'
break
case searchInclude.slice(0, index).includes('discord'):
case display_name.includes('discord'):
svg = 'discord'
break
case display_name.includes('KeyCloak'):
svg = 'keycloak'
break
}
return svg
},
Expand All @@ -325,13 +326,21 @@ export default {
state,
code
})
.then(() => {
const { origin } = window.location
window.location.pathname = ''
window.location.search = ''
window.location = origin
.then(response => {
this.$router.push({
path: this.redirect || '/',
query: {
...this.otherQuery,
action: this.$route.query.recordUuid
}
}, () => {})
})
.catch(error => {
const href = window.location.href
if (href.includes('state=')) {
const index = href.indexOf('state=')
window.location.href = href.substring(0, index)
}
let message = this.$t('page.login.unexpectedError')
if ([13, 500].includes(error.code)) {
message = this.$t('page.login.invalidLogin')
Expand Down

0 comments on commit ec39167

Please sign in to comment.