Skip to content

Commit

Permalink
fix: do not create openid session on device auth request
Browse files Browse the repository at this point in the history
  • Loading branch information
nsklikas committed Nov 18, 2024
1 parent 9753bcd commit c778674
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions handler/openid/flow_device_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ type OpenIDConnectDeviceHandler struct {
}

func (c *OpenIDConnectDeviceHandler) HandleDeviceEndpointRequest(ctx context.Context, dar fosite.DeviceRequester, resp fosite.DeviceResponder) error {
// We don't want to create the openid session on this call, because we don't know if the user
// will actually complete the flow and give consent. The implementer MUST call the CreateOpenIDConnectSession
// methods when the user logs in to instantiate the session.
if !(dar.GetRequestedScopes().Has("openid")) {
return nil
}
Expand All @@ -37,14 +40,5 @@ func (c *OpenIDConnectDeviceHandler) HandleDeviceEndpointRequest(ctx context.Con
return errorsx.WithStack(fosite.ErrMisconfiguration.WithDebug("The device code has not been issued yet, indicating a broken code configuration."))
}

signature, err := c.DeviceCodeStrategy.DeviceCodeSignature(ctx, resp.GetDeviceCode())
if err != nil {
return err
}

if err := c.OpenIDConnectRequestStorage.CreateOpenIDConnectSession(ctx, signature, dar.Sanitize(oidcParameters)); err != nil {
return errorsx.WithStack(fosite.ErrServerError.WithWrap(err).WithDebug(err.Error()))
}

return nil
}

0 comments on commit c778674

Please sign in to comment.