MCPcopy
hub / github.com/zitadel/oidc / ParseDeviceCodeRequest

Function ParseDeviceCodeRequest

pkg/op/device.go:133–157  ·  view source on GitHub ↗
(r *http.Request, o OpenIDProvider)

Source from the content-addressed store, hash-verified

131}
132
133func ParseDeviceCodeRequest(r *http.Request, o OpenIDProvider) (*oidc.DeviceAuthorizationRequest, error) {
134 ctx, span := Tracer.Start(r.Context(), "ParseDeviceCodeRequest")
135 r = r.WithContext(ctx)
136 defer span.End()
137
138 clientID, _, err := ClientIDFromRequest(r, o)
139 if err != nil {
140 return nil, err
141 }
142 client, err := o.Storage().GetClientByClientID(r.Context(), clientID)
143 if err != nil {
144 return nil, err
145 }
146 if !ValidateGrantType(client, oidc.GrantTypeDeviceCode) {
147 return nil, oidc.ErrUnauthorizedClient().WithDescription("client missing grant type " + string(oidc.GrantTypeDeviceCode))
148 }
149
150 req := new(oidc.DeviceAuthorizationRequest)
151 if err := o.Decoder().Decode(req, r.Form); err != nil {
152 return nil, oidc.ErrInvalidRequest().WithDescription("cannot parse device authentication request").WithParent(err)
153 }
154 req.ClientID = clientID
155
156 return req, nil
157}
158
159// 16 bytes gives 128 bit of entropy.
160// results in a 22 character base64 encoded string.

Callers 2

DeviceAuthorizationFunction · 0.85

Calls 10

ClientIDFromRequestFunction · 0.85
ValidateGrantTypeFunction · 0.85
StartMethod · 0.80
EndMethod · 0.80
WithDescriptionMethod · 0.80
DecodeMethod · 0.80
WithParentMethod · 0.80
GetClientByClientIDMethod · 0.65
StorageMethod · 0.65
DecoderMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…