Skip to content

Commit

Permalink
fix: always issue session last (#3876)
Browse files Browse the repository at this point in the history
In post persist hooks, the session issuance hook always needs
to come last. This fixes the getHooks function to ensure this.
  • Loading branch information
hperl authored Apr 17, 2024
1 parent 9fa25b5 commit e942507
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion driver/registry_default_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
}

0 comments on commit e942507

Please sign in to comment.