Skip to content

Commit

Permalink
core/databroker: disable identity manager user refresh when hosted au…
Browse files Browse the repository at this point in the history
…thenticate is used (#4905)
  • Loading branch information
calebdoxsey committed Jan 12, 2024
1 parent 1080a33 commit 5e0079c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,24 @@ func (o *Options) UseStatelessAuthenticateFlow() bool {
return urlutil.IsHostedAuthenticateDomain(u.Hostname())
}

// SupportsUserRefresh returns true if the config options support refreshing of user sessions.
func (o *Options) SupportsUserRefresh() bool {
if o == nil {
return false
}

if o.Provider == "" {
return false
}

u, err := o.GetInternalAuthenticateURL()
if err != nil {
return false
}

return !urlutil.IsHostedAuthenticateDomain(u.Hostname())
}

// GetAuthorizeURLs returns the AuthorizeURLs in the options or 127.0.0.1:5443.
func (o *Options) GetAuthorizeURLs() ([]*url.URL, error) {
if IsAll(o.Services) && o.AuthorizeURLString == "" && len(o.AuthorizeURLStrings) == 0 {
Expand Down
4 changes: 3 additions & 1 deletion databroker/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,15 @@ func (c *DataBroker) update(ctx context.Context, cfg *config.Config) error {
manager.WithEventManager(c.eventsMgr),
}

if cfg.Options.Provider != "" {
if cfg.Options.SupportsUserRefresh() {
authenticator, err := identity.NewAuthenticator(oauthOptions)
if err != nil {
log.Error(ctx).Err(err).Msg("databroker: failed to create authenticator")
} else {
options = append(options, manager.WithAuthenticator(authenticator))
}
} else {
log.Info(ctx).Msg("databroker: disabling refresh of user sessions")
}

if c.manager == nil {
Expand Down

0 comments on commit 5e0079c

Please sign in to comment.