navikt / mock-oauth2-server

A scriptable/customizable web server for testing HTTP clients using OAuth2/OpenID Connect or applications with a dependency to a running OAuth2 server (i.e. APIs requiring signed JWTs from a known issuer)
MIT License
224 stars 55 forks source link

requestParam "scope" in tokenCallbacks not working #712

Open pniederlag opened 1 week ago

pniederlag commented 1 week ago

I was trying to use tokenCallbacks in standalone mock-server und heavily struggled to get it working.

requestParam dummy is working

"tokenCallbacks": [
          {
            "issuerId": "fetest",
            "requestMappings": [
              {
                "requestParam": "dummy",
                "match": "example",

curl -sS --header 'Origin: http://oidc-server-mock' --header 'Content-Type: application/x-www-form-urlencoded' --header 'Authorization: Basic ZmV0ZXN0Onh5eg==' --data 'claims=test' --data 'grant_type=authorization%5Fcode' --data 'code=0wVQWnvQD6azoKvXdmi3rxjsZ0F8PNdxaKXpUa%5FQLhc' --data 'dummy=example' --data 'redirect_uri=http%253A%252F%252Foidc%2Dserver%2Dmock%252Ffetest%252Fdebugger%252Fcallback' 'http://oidc-server-mock/fetest/token' | jq '.access_token'

Doing the very same with requestParam scope is however not working.

mm326 commented 1 week ago

the scope request param is no logner supported by nimbus https://github.com/navikt/mock-oauth2-server/commit/c9607571743cc087b190112f2197f4ac0a27aef2 so you need to configure the call back with a different key