feat: provide logout url for openid providers (#1340)
Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/1340 Co-authored-by: viehlieb <pf@pragma-shift.net> Co-committed-by: viehlieb <pf@pragma-shift.net>
This commit is contained in:
parent
e9ce930230
commit
a79b1de2d0
@ -311,6 +311,9 @@ auth:
|
|||||||
- name:
|
- name:
|
||||||
# The auth url to send users to if they want to authenticate using OpenID Connect.
|
# The auth url to send users to if they want to authenticate using OpenID Connect.
|
||||||
authurl:
|
authurl:
|
||||||
|
# The oidc logouturl that users will be redirected to on logout.
|
||||||
|
# Leave empty or delete key, if you do not want to be redirected.
|
||||||
|
logouturl:
|
||||||
# The client ID used to authenticate Vikunja at the OpenID Connect provider.
|
# The client ID used to authenticate Vikunja at the OpenID Connect provider.
|
||||||
clientid:
|
clientid:
|
||||||
# The client secret used to authenticate Vikunja at the OpenID Connect provider.
|
# The client secret used to authenticate Vikunja at the OpenID Connect provider.
|
||||||
|
@ -51,6 +51,7 @@ type Provider struct {
|
|||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
OriginalAuthURL string `json:"-"`
|
OriginalAuthURL string `json:"-"`
|
||||||
AuthURL string `json:"auth_url"`
|
AuthURL string `json:"auth_url"`
|
||||||
|
LogoutURL string `json:"logout_url"`
|
||||||
ClientID string `json:"client_id"`
|
ClientID string `json:"client_id"`
|
||||||
ClientSecret string `json:"-"`
|
ClientSecret string `json:"-"`
|
||||||
openIDProvider *oidc.Provider
|
openIDProvider *oidc.Provider
|
||||||
|
@ -60,6 +60,7 @@ func GetAllProviders() (providers []*Provider, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
provider, err := getProviderFromMap(pi)
|
provider, err := getProviderFromMap(pi)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if provider != nil {
|
if provider != nil {
|
||||||
log.Errorf("Error while getting openid provider %s: %s", provider.Name, err)
|
log.Errorf("Error while getting openid provider %s: %s", provider.Name, err)
|
||||||
@ -119,12 +120,18 @@ func getProviderFromMap(pi map[string]interface{}) (provider *Provider, err erro
|
|||||||
|
|
||||||
k := getKeyFromName(name)
|
k := getKeyFromName(name)
|
||||||
|
|
||||||
|
logoutURL, ok := pi["logouturl"].(string)
|
||||||
|
if !ok {
|
||||||
|
logoutURL = ""
|
||||||
|
}
|
||||||
|
|
||||||
provider = &Provider{
|
provider = &Provider{
|
||||||
Name: pi["name"].(string),
|
Name: pi["name"].(string),
|
||||||
Key: k,
|
Key: k,
|
||||||
AuthURL: pi["authurl"].(string),
|
AuthURL: pi["authurl"].(string),
|
||||||
OriginalAuthURL: pi["authurl"].(string),
|
OriginalAuthURL: pi["authurl"].(string),
|
||||||
ClientSecret: pi["clientsecret"].(string),
|
ClientSecret: pi["clientsecret"].(string),
|
||||||
|
LogoutURL: logoutURL,
|
||||||
}
|
}
|
||||||
|
|
||||||
cl, is := pi["clientid"].(int)
|
cl, is := pi["clientid"].(int)
|
||||||
@ -143,7 +150,6 @@ func getProviderFromMap(pi map[string]interface{}) (provider *Provider, err erro
|
|||||||
ClientID: provider.ClientID,
|
ClientID: provider.ClientID,
|
||||||
ClientSecret: provider.ClientSecret,
|
ClientSecret: provider.ClientSecret,
|
||||||
RedirectURL: config.AuthOpenIDRedirectURL.GetString() + k,
|
RedirectURL: config.AuthOpenIDRedirectURL.GetString() + k,
|
||||||
|
|
||||||
// Discovery returns the OAuth2 endpoints.
|
// Discovery returns the OAuth2 endpoints.
|
||||||
Endpoint: provider.openIDProvider.Endpoint(),
|
Endpoint: provider.openIDProvider.Endpoint(),
|
||||||
|
|
||||||
|
@ -9099,6 +9099,9 @@ const docTemplate = `{
|
|||||||
"key": {
|
"key": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"logout_url": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -9090,6 +9090,9 @@
|
|||||||
"key": {
|
"key": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"logout_url": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -1120,6 +1120,8 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
key:
|
key:
|
||||||
type: string
|
type: string
|
||||||
|
logout_url:
|
||||||
|
type: string
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user