We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oauth2
Describe the bug The oauth2 (cc) block does not use the referenced but a default backend
To Reproduce Steps to reproduce the behavior:
couper version
docker run avenga/couper version
$ couper version 0 2021-09-28 dev
*.hcl
# OAuth2 client server "oauth2-cc-client" { hosts = ["*:8080"] api { endpoint "/**" { proxy { backend = "rs" } } } } # OAuth2 resource server server "oauth2-rs" { hosts = ["*:8081"] api { access_control = ["jwt"] endpoint "/**" { response { json_body = request.context.jwt } } } } # OAuth2 authorization server server "oauth2-as" { hosts = ["*:8082"] api { endpoint "/token" { response { json_body = { access_token = jwt_sign("jwt", { foo = request.headers.x-foo }) expires_in = 120 } } } } } definitions { # backend for resource server backend "rs" { origin = "http://localhost:8081" oauth2 { token_endpoint = "http://localhost:8082/token" backend = "as" client_id = "id" client_secret = "secret" grant_type = "client_credentials" } } # backend for authorization server backend "as" { origin = "http://localhost:8082" add_request_headers = { x-foo = "bar" } } # jwt for signing (at authorization server) and signature validation (at resource server) jwt "jwt" { signature_algorithm = "HS256" header = "authorization" key = "$e(rEt" signing_ttl = "120s" claims = { foo = "bar" } } }
curl
$ curl -si localhost:8080/foo
$ curl -si localhost:8080/foo HTTP/1.1 502 Bad Gateway Content-Type: application/json Couper-Error: backend error Couper-Request-Id: c59enjl916bmb43dn3tg Server: couper.io Vary: Accept-Encoding Date: Tue, 28 Sep 2021 10:17:50 GMT Content-Length: 134 { "error": { "id": "c59enjl916bmb43dn3tg", "message": "backend error", "path": "/foo", "status": 502 } }
ERRO[0006] expression evaluation error: couper.hcl:29,65-71: Missing map element; This map does not have an element with the key "x-foo". auth_user=id build=dev client_ip=127.0.0.1 endpoint=/token error_type=evaluation handler=api method=POST port=8082 request="map[bytes:29 headers:map[accept:application/json] host:localhost method:POST origin:localhost:8082 path:/token proto:http status:500 tls:false]" response="map[bytes:150 headers:map[content-type:application/json]]" server=oauth2-as status=500 timings="map[total:0.631]" type=couper_access uid=c59enjl916bmb43dn3u0 url="http://localhost:8082/token" version=0 INFO[0006] auth_user=id backend=default build=dev method=POST request="map[bytes:29 headers:map[accept:application/json] host:localhost method:POST name:default origin:localhost:8082 path:/token port:8082 proto:]" response="map[headers:map[content-type:application/json] status:500]" status=500 timings="map[dns:5.014 tcp:0.658 total:12.556 ttfb:5.763]" token_request=oauth2 type=couper_backend uid=c59enjl916bmb43dn3tg url="http://localhost:8082/token" version=0 ERRO[0006] backend error: as: token request error: error= build=dev client_ip=127.0.0.1 endpoint="/**" handler=api method=GET port=8080 request="map[headers:map[accept:*/* user-agent:curl/7.67.0] host:localhost method:GET origin:localhost:8080 path:/foo proto:http status:502 tls:false]" response="map[bytes:134 headers:map[content-type:application/json]]" server=oauth2-cc-client status=502 timings="map[total:14.752]" type=couper_access uid=c59enjl916bmb43dn3tg url="http://localhost:8080/foo" version=0
x-foo
default
as
Expected behavior
foo
$ curl -si localhost:8080/foo HTTP/1.1 200 OK ... {"exp":...,"foo":"bar"}
backend=as
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe the bug
The
oauth2
(cc) block does not use the referenced but a default backendTo Reproduce
Steps to reproduce the behavior:
couper version
ordocker run avenga/couper version
*.hcl
. Remove sensitive data.curl
call for reproductionx-foo
header.default
backend, not the one labelledas
.Expected behavior
as
backend which adds ax-foo
request header which is then used at the token endpoint to add an extrafoo
claim:backend=as
.The text was updated successfully, but these errors were encountered: