Skip to content

Commit

Permalink
wip: Allow to provide access to the site using a referrer policy #11
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Jul 3, 2024
1 parent 7c849e1 commit 79a531c
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions layouts/KeycloakLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,16 @@ const hasAccess = ref(false)
// Functions
function passReferrer () {
console.log(document.referrer)
if (!document.referrer) return false
let subdomains = _.get(theme.value, 'referrer.subdomains', [])
console.log(subdomains)
if (!Array.isArray(subdomains)) {
console.log('array', subdomains)
subdomains = _.split(subdomains, ',')
}
console.log(subdomains)
if (!Array.isArray(subdomains)) subdomains = _.split(subdomains, ',')
let pass = false
_.forEach(subdomains, subdomain => {
if (document.referrer.includes(subdomain)) {
pass = true
return false
}
})
console.log(pass)
return pass
}
function passKeycloak () {
Expand All @@ -61,14 +54,12 @@ function passKeycloak () {
onMounted(() => {
const useReferrer = (_.isBoolean(theme.value.useReferrer) && theme.value.useReferrer) || theme.value.useReferrer === 'true'
const useKeycloak = (_.isBoolean(theme.value.useKeycloak) && theme.value.useKeycloak) || theme.value.useKeycloak === 'true'
console.log(useReferrer, useKeycloak)
if (useReferrer) {
hasAccess.value = passReferrer()
}
if (!hasAccess.value) {
if (useKeycloak) {
hasAccess.value = passKeycloak()
hasAccess.value = true
} else {
hasAccess.value = !useReferrer
}
Expand Down

0 comments on commit 79a531c

Please sign in to comment.