MCPcopy Create free account
hub / github.com/zitadel/oidc / CreateAuthRequest

Method CreateAuthRequest

example/server/storage/storage.go:175–196  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

173// CreateAuthRequest implements the op.Storage interface
174// it will be called after parsing and validation of the authentication request
175func (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

Callers

nothing calls this directly

Implementers 7

Storageexample/server/storage/storage.go
multiStorageexample/server/storage/storage_dynamic
UnimplementedServerpkg/op/server.go
LegacyServerpkg/op/server_legacy.go
Sigpkg/op/mock/authorizer.mock.impl.go
MockStoragepkg/op/mock/storage.mock.go
MockStorageMockRecorderpkg/op/mock/storage.mock.go

Calls 1

authRequestToInternalFunction · 0.85

Tested by

no test coverage detected