3scale / APIcast

3scale API Gateway
Apache License 2.0
305 stars 170 forks source link

THREESCALE-11015 - Support client_secret_jwt and private_key_jwt as authentication type for token introspection policy #1464

Closed tkan145 closed 4 months ago

tkan145 commented 6 months ago

Known issue

Some time failed with the following error

/opt/app-root/src/gateway/src/apicast/policy_loader.lua:98: Invalid config for policy: failed to validate dependent schema for "auth_type": value should match only one schema, but matches none

This is due to the use of oneOf and seems like a bug. I will need to investigate this further.

The original intention was to add support for a single algorithm and then upgrade lua-retsy-jwt afterwards and have a minimal schema structure change. However, the jsonschema validation fails when the emum field only contains a single value so I decided to remove it for now.

@eguzki if you know a better way to build apicast-config.json or how to solve this problem, please let me know


What

This PR mainly adding 2 new authentication method for token introspection policy, client_secret_jwt and private_key_jwt.

JIRA: https://issues.redhat.com/browse/THREESCALE-11015 Reference: https://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication

Why only HS256 and RS256 are supported?

This is due to the version of lua-resty-jwt (0.20) that we use

Support sign algorithm

RHKB 24 lua-resty-jwt 0.20 lua-resty-0.2.2 lua-resty-0.2.3
client_secret_jwt HS256
HS384
HS512
HS256
HS512
HS256
HS512
HS256
HS512
private_key_jwt RS256
RS382
RS512
ES256
ES384
ES512
PS256
PS384
PS512
RS256 RS256
ES256
RS256
RS512
ES256
ES512

Highest we can go is 0.2.2 but this only add support for ES256 0.2.3 introduce a new dependency lua-resty-openssl. See https://github.com/3scale/APIcast/issues/1375#issuecomment-1281071040

Eventually we will need an update but given the amount of work involved, I'd like to keep version 0.20 for now

Verification steps:

Validate client_secret_jwt authentication method