Skip to content

Commit 9161b88

Browse files
committed
only load config in pathPoll when in device flow
1 parent 4c8e6a3 commit 9161b88

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

path_oidc.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,6 @@ func (b *jwtAuthBackend) processToken(ctx context.Context, config *jwtConfig, oi
405405

406406
// second half of the client API for direct and device callback modes
407407
func (b *jwtAuthBackend) pathPoll(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
408-
config, err := b.config(ctx, req.Storage)
409-
if err != nil {
410-
return nil, err
411-
}
412-
if config == nil {
413-
return logical.ErrorResponse(errLoginFailed + " Could not load configuration"), nil
414-
}
415-
416408
stateID := d.Get("state").(string)
417409
state := b.getState(stateID)
418410
if state == nil {
@@ -442,6 +434,14 @@ func (b *jwtAuthBackend) pathPoll(ctx context.Context, req *logical.Request, d *
442434
}
443435

444436
if role.CallbackMode == callbackModeDevice {
437+
config, err := b.config(ctx, req.Storage)
438+
if err != nil {
439+
return nil, err
440+
}
441+
if config == nil {
442+
return logical.ErrorResponse(errLoginFailed + " Could not load configuration"), nil
443+
}
444+
445445
caCtx, err := b.createCAContext(ctx, config.OIDCDiscoveryCAPEM)
446446
if err != nil {
447447
return nil, err

0 commit comments

Comments
 (0)