From e94250705e999567e2ed58cebdb3f6a9d589e3ef Mon Sep 17 00:00:00 2001 From: Henning Perl Date: Wed, 17 Apr 2024 13:30:04 +0200 Subject: [PATCH] fix: always issue session last (#3876) In post persist hooks, the session issuance hook always needs to come last. This fixes the getHooks function to ensure this. --- driver/registry_default_hooks.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/driver/registry_default_hooks.go b/driver/registry_default_hooks.go index 05b9a10f3d98..73a855daadc5 100644 --- a/driver/registry_default_hooks.go +++ b/driver/registry_default_hooks.go @@ -62,10 +62,12 @@ func (m *RegistryDefault) WithHooks(hooks map[string]func(config.SelfServiceHook } func (m *RegistryDefault) getHooks(credentialsType string, configs []config.SelfServiceHook) (i []interface{}) { + var addSessionIssuer bool for _, h := range configs { switch h.Name { case hook.KeySessionIssuer: - i = append(i, m.HookSessionIssuer()) + // The session issuer hook always needs to come last. + addSessionIssuer = true case hook.KeySessionDestroyer: i = append(i, m.HookSessionDestroyer()) case hook.KeyWebHook: @@ -96,6 +98,9 @@ func (m *RegistryDefault) getHooks(credentialsType string, configs []config.Self Errorf("A unknown hook was requested and can therefore not be used") } } + if addSessionIssuer { + i = append(i, m.HookSessionIssuer()) + } return i }