(r *http.Request, o OpenIDProvider)
| 131 | } |
| 132 | |
| 133 | func 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. |
searching dependent graphs…