ory/hydra

`loginRequest.requested_access_token_audience` should not be `null`

Closed this issue · 7 comments

Describe the bug

In openapi schema, field requested_access_token_audience is required, which means it cannot be null.

But what I received is:

{
   "challenge":"eaf5b69b16a441b5a861b8a71c818c0a",
   "requested_scope":[
      "openid",
      "offline",
      "profile:read",
      "email"
   ],
   "requested_access_token_audience":null, // <--- `null` here
   "skip":false,
   "subject":"",
   "oidc_context":{
      
   },
   "client":{
      "client_id":"absolem-ui",
      "client_name":"Absolem Frontend Client",
      "redirect_uris":[
         "http://127.0.0.1:4455/callback"
      ],
      "grant_types":[
         "authorization_code",
         "refresh_token"
      ],
      "response_types":[
         "code",
         "token",
         "id_token"
      ],
      "scope":"openid offline profile:read email",
      "audience":null,
      "owner":"",
      "policy_uri":"",
      "allowed_cors_origins":null,
      "tos_uri":"",
      "client_uri":"",
      "logo_uri":"",
      "contacts":null,
      "client_secret_expires_at":0,
      "subject_type":"public",
      "token_endpoint_auth_method":"none",
      "userinfo_signed_response_alg":"none",
      "created_at":"2020-09-04T15:54:55Z",
      "updated_at":"2020-09-04T15:54:55Z"
   },
   "request_url":"http://127.0.0.1:4455/.ory/hydra/public/oauth2/auth?client_id=absolem-ui\u0026redirect_uri=http%3A%2F%2F127.0.0.1%3A4455%2Fcallback\u0026response_type=code\u0026scope=openid%20offline%20profile%3Aread%20email\u0026state=89c3a3a0cfac4ed183fc05ee60e3b652\u0026code_challenge=vqvX01wjsrnwC5YQM3I80ep_XbS_nd-CHE-VxJry5dc\u0026code_challenge_method=S256\u0026response_mode=query",
   "session_id":"ec73cd37-8aac-4d40-998c-e5e5164fde23"
}

Reproducing the bug

Steps to reproduce the behavior:

  1. GET http://<hydra>:4455/oauth2/auth/requests/login?login_challenge=xxx
  2. You will see it

Expected behavior

EVERY required fields should not be null

Environment

  • Version: v1.7.4
  • Env: Docker

Additional context

BTW, I am trying to use the generated Rust clients (by openapi-generator). Because Rust is a strict language (for example, null safety), some bugs will be exposed easier than Java or Go generated client

Right, this happens when the go array is initialized as a nil value as opposed to an empty string slice! Tracking as a bug - contribs welcomed!

I just read the code. As you said go array is initialized as a nil value. So obviously we cannot use:

type MemoryManager struct {
...
	authRequests           map[string]LoginRequest
...
}

but should use:

type MemoryManager struct {
...
	authRequests           map[string]*LoginRequest // <-- Pointer here
...
}

Then we should use something like:

func NewLoginRequest(...) LoginRequest {
    return LoginRequest{ authRequests: []string{} }
}

BTW, I found that this error only happened in memory manager, because SQL manager uses another initialization methods

Ah, that is quite possible. The plan is to deprecate the Memory Manager and replace it with a SQLite in memory database, in which case this error would disappear. Given that, and that the in-memory manager is only used for dev / quickstarts, I think we can keep this as a nofix with a known workaround!

Yes, I do use memory just for dev, and 👍 for SQLite

SQLite is now merged.