-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
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
When tokenType = jwt, scope restriction doesn't work. #684
Comments
As a self reminder, we have two issues here:
|
Because talking about possibilities with JWT is always confusing, I'm just going to take a moment to provide a refresher on different ways JWTs manifest in authentication/authorization. There are actually 3 ways we could potentially use JWT in a gateway.
I think in use cases 1 and 3, we could potentially take JWTs issued by an Identity Provider, and in those cases, we'd need some indication of assigned scopes, likely via a custom claim. For use case 2, I think we'd have to manage all of that internally. And if we're managing it internally, we should be able to take advantage of our scope management. I think this issue is referring to use case 2, which should not require a custom @naorbe Feel free to comment if I'm missing something. |
So it looks like we don't run a scope authorization check when the OAuth2 access token is a JWT. We can do something like this in the OAuth2 use case for JWTs. This is what we're doing for opaque tokens: https://github.com/ExpressGateway/express-gateway/blob/master/lib/policies/oauth2/oauth2.js#L44-L66 Currently, we're just re-utilizing the JWT policy for the OAuth2 use case. @XVincentX, would it be as simple as running that above logic for JWTs in OAuth2 or am I missing an important aspect that would prevent it? |
I think I have a similar use case to this
I have set up scope, created a JWT token and added the scope in the payload but EG doesnot restricts it. |
Yes — you're experiencing exactly the same issue. I wrote you a workaround in the Gitter channel (that is — use this) |
@XVincentX: Thanks! As your guide, I can fix this issue by add jwtScopes policy. Please add an "actionParam" to choose JWT scope field in your jwt policy. So we will not need jwtScopes anymore. |
@kevinswiber: You said "I think this issue is referring to use case 2, which should not require a custom scopes claim in the JWT. Scope management should work for JWT access tokens the same exact way it works for opaque access tokens.". I think so but "scope" in OAuth2 token is standard and many node package is doing the same way. So maybe we have to do as @XVincentX noted :) |
@naprime What policy are you referring to? |
@XVincentX : I means you should add one more param to select which "scope" user defined in your JWT plugin (https://www.express-gateway.io/docs/policies/jwt/) |
Have you solved this Issue ? @alamgirqazi |
EDIT:(For anyone who fac[ed|ing] this issue.)
(after talking to Vincenzo)
Tried to restrict an apiEndpoint with scopes, and any logged user , with any role, could pass through to the proxy level.
After few tries, I figured this case happens only when the tokenType is "jwt".
When commenting the tokenType with it's props (issuer, audience,subject), the scopes restriction works perfectly.
Config references (bugged reference as reproduce steps):
apiEndpoint :
pipeline :
systemConfig.accessTokens :
The text was updated successfully, but these errors were encountered: