MCPcopy
hub / github.com/ory/hydra / GetUserCodeSession

Method GetUserCodeSession

persistence/sql/persister_device.go:212–237  ·  view source on GitHub ↗

GetUserCodeSession returns a user code session from the database. Implements FositeStorer.

(ctx context.Context, signature string, session fosite.Session)

Source from the content-addressed store, hash-verified

210
211// GetUserCodeSession returns a user code session from the database. Implements FositeStorer.
212func (p *Persister) GetUserCodeSession(ctx context.Context, signature string, session fosite.Session) (_ fosite.DeviceRequester, err error) {
213 ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.GetUserCodeSession")
214 defer otelx.End(span, &err)
215
216 r := DeviceRequestSQL{}
217 if session == nil {
218 session = oauth2.NewSessionWithCustomClaims(ctx, p.r.Config(), "")
219 }
220
221 if err = p.QueryWithNetwork(ctx).Where("user_code_signature = ?", signature).First(&r); errors.Is(err, sql.ErrNoRows) {
222 return nil, errors.WithStack(fosite.ErrNotFound)
223 } else if err != nil {
224 return nil, sqlcon.HandleError(err)
225 }
226
227 fr, err := r.toRequest(ctx, session, p)
228 if err != nil {
229 return nil, err
230 }
231
232 if r.UserCodeState != fosite.UserCodeUnused {
233 return fr, errors.WithStack(fosite.ErrInactiveToken)
234 }
235
236 return fr, err
237}
238
239// GetDeviceCodeSessionByRequestID returns a device code session from the database. Implements FositeStorer.
240func (p *Persister) GetDeviceCodeSessionByRequestID(ctx context.Context, requestID string, session fosite.Session) (_ fosite.DeviceRequester, deviceCodeSignature string, err error) {

Callers

nothing calls this directly

Implementers 1

BasePersisterpersistence/sql/persister.go

Calls 6

toRequestMethod · 0.95
QueryWithNetworkMethod · 0.80
TracerMethod · 0.65
ConfigMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected