CreateAuthRequest implements the op.Storage interface it will be called after parsing and validation of the authentication request
(ctx context.Context, authReq *oidc.AuthRequest, userID string)
| 173 | // CreateAuthRequest implements the op.Storage interface |
| 174 | // it will be called after parsing and validation of the authentication request |
| 175 | func (s *Storage) CreateAuthRequest(ctx context.Context, authReq *oidc.AuthRequest, userID string) (op.AuthRequest, error) { |
| 176 | s.lock.Lock() |
| 177 | defer s.lock.Unlock() |
| 178 | |
| 179 | if len(authReq.Prompt) == 1 && authReq.Prompt[0] == "none" { |
| 180 | // With prompt=none, there is no way for the user to log in |
| 181 | // so return error right away. |
| 182 | return nil, oidc.ErrLoginRequired() |
| 183 | } |
| 184 | |
| 185 | // typically, you'll fill your storage / storage model with the information of the passed object |
| 186 | request := authRequestToInternal(authReq, userID) |
| 187 | |
| 188 | // you'll also have to create a unique id for the request (this might be done by your database; we'll use a UUID) |
| 189 | request.ID = uuid.NewString() |
| 190 | |
| 191 | // and save it in your database (for demonstration purposed we will use a simple map) |
| 192 | s.authRequests[request.ID] = request |
| 193 | |
| 194 | // finally, return the request (which implements the AuthRequest interface of the OP |
| 195 | return request, nil |
| 196 | } |
| 197 | |
| 198 | // AuthRequestByID implements the op.Storage interface |
| 199 | // it will be called after the Login UI redirects back to the OIDC endpoint |
nothing calls this directly
no test coverage detected