mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-27 11:41:36 +00:00
Add support for forward proxy auth. Tested with authentik.
- adds new method (`getUserFromProxyAuth) to server/Auth.js to check for relevant environment variables and pull the user from the request headers.. - adds `/forwardauth` route to call new proxy auth method - modified /client/login.vue to call `/forwardauth` and authenticate the user if returned by forwardauth - add a helper method in `server/utils/parseBool.js` to help check for boolean values from environment - update the readme.md to explain how enable forward auth.
This commit is contained in:
parent
765a11f135
commit
b8d0395e6d
5 changed files with 111 additions and 0 deletions
|
|
@ -137,6 +137,34 @@ export default {
|
|||
this.$store.commit('libraries/setCurrentLibrary', userDefaultLibraryId)
|
||||
this.$store.commit('user/setUser', user)
|
||||
},
|
||||
/**
|
||||
* Checks for forward proxy authentication
|
||||
*/
|
||||
async checkForwardAuth() {
|
||||
this.processing = true;
|
||||
this.error = null;
|
||||
|
||||
var authRes = await this.$axios.$post('/forwardauth').catch((error) => {
|
||||
console.error('Failed', error.response)
|
||||
if (error.response) this.error = error.response.data
|
||||
else this.error = 'Unknown Error'
|
||||
return false
|
||||
});
|
||||
|
||||
if (authRes && authRes.disabled) {
|
||||
// disabled == true - proxy auth has not been configured on the server, nothing further to do.
|
||||
this.processing = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (authRes && authRes.error) {
|
||||
this.error = authRes.error
|
||||
} else if (authRes) {
|
||||
this.setUser(authRes)
|
||||
}
|
||||
this.processing = false
|
||||
|
||||
},
|
||||
async submitForm() {
|
||||
this.error = null
|
||||
this.processing = true
|
||||
|
|
@ -202,6 +230,10 @@ export default {
|
|||
}
|
||||
},
|
||||
async mounted() {
|
||||
|
||||
// Check for proxy auth
|
||||
this.checkForwardAuth();
|
||||
|
||||
if (localStorage.getItem('token')) {
|
||||
var userfound = await this.checkAuth()
|
||||
if (userfound) return // if valid user no need to check status
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue