(ctx context.Context, d decodeDependencies, enc string, p purpose)
| 23 | } |
| 24 | |
| 25 | func decodeFlow(ctx context.Context, d decodeDependencies, enc string, p purpose) (_ *Flow, err error) { |
| 26 | f, err := Decode[Flow](ctx, d.FlowCipher(), enc, withPurpose(p)) |
| 27 | if err != nil { |
| 28 | return nil, errors.WithStack(x.ErrNotFound.WithWrap(err)) |
| 29 | } |
| 30 | |
| 31 | if f.NID != d.Networker().NetworkID(ctx) { |
| 32 | return nil, errors.WithStack(x.ErrNotFound.WithDescription("Network IDs are not matching.")) |
| 33 | } |
| 34 | |
| 35 | if f.RequestedAt.Add(d.Config().ConsentRequestMaxAge(ctx)).Before(time.Now()) { |
| 36 | return nil, errors.WithStack(fosite.ErrRequestUnauthorized.WithHintf("The %s request has expired, please try again.", p.RequestType())) |
| 37 | } |
| 38 | |
| 39 | return f, nil |
| 40 | } |
| 41 | |
| 42 | func DecodeFromLoginChallenge(ctx context.Context, d decodeDependencies, challenge string) (_ *Flow, err error) { |
| 43 | ctx, span := d.Tracer(ctx).Tracer().Start(ctx, "flow.DecodeFromLoginChallenge") |
no test coverage detected