-
Notifications
You must be signed in to change notification settings - Fork 44
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
using yaml for token config #181
Comments
As long as the |
I tried quoting the string: |
Is below ok to check if the header doesn't exist?
|
Actually, I just tested it and you've found a bug in the library (https://github.com/dchester/jsonpath) the problem has nothing to do with the As an alternative use another query engine. For example if you allow eval you can use the
|
Glad you were able to reproduce and thanks for the alternative way. I tried it and got:
Then I set env EAS_ALLOW_EVAL to 1, but got another error when sending a request without jwt header:
Finally sending a request with real jwt header:
(seems same error as if I were to not send jwt header at all. |
Did you remove the |
Yes I did:
|
BTW, the bug you found in jsonpath doesn't seem to exist in jsonata, so if I use
so I can skip if the header doesn't exist. I tried but the engine seems to treat "undefined" as literal string match :( |
You still need the rule with the js engine as well FYI. I think the regex syntax you had may work if you simply to |
Tried but didn't work. |
I’ll look at this later in the day and get you a working example. |
I think this will work with the existing codebase: - query_engine: js
query: "try { return data.req.headers[\"my-jwt-header\"]; } catch (e) { return ''; }"
rule:
method: regex
value: /\w/i
negate: true Give it a try and let me know. I have some minor fixes to commit to make this work better due to javascript oddities but the above should do what you want. |
It doesn't seem to work. When I send a request without jwt header, I expect to see "skipping plugin due to pcb", something like:
but I saw below instead:
|
Maybe I don't need this pcb rule. I assume the default jwt plugin will already do the same: skip to next plugin if jwt header doesn't exist. |
Yes it will. I typically would use the skip also with a stop (this helps ensure the response to applicable clients is more focused and relevant to the client). For example you don’t really want to redirect a machine to an oauth endpoint. I think I know why you’re getting that, let me try 1 more variation and send it your way. |
Yeah, update the
|
Can you clarify the skip/stop? My understanding is: "skip" will go to next plugin without running the current plugin, but "stop" will NOT stop running the current plugin, it will still run the current plugin, just stop AFTER it finishes and won't go to next plugin. In my test case, since "skip" is implicit behavior of jwt plugin (it will directly go to next plugin if the jwt header doesn't exist), I only need a "stop" pcb where jwt header exists?
Yes, this works! Thanks! |
A |
I tried below pcb "stop", without "skip":
Now if I send a request without the jwt header, it actually goes to the next plugin:
If I send the request with jwt header, it will stop at jwt plugin, whether the header is valid or not. In case an invalid jwt header, the plugin returns 401 and stops there. The problem is ingress-nginx will trigger the oauth redirect anyway when it gets 401 from "external-auth-server". I am using this nginx ingress config example. Client side gets 302 |
Oh right, that should work. The performance gains of using Regarding the empty |
The empty rd in this case is expected because we put a stop at the jwt plugin and rd only makes sense for oauth/oidc plugins. What I tried to say in last post was the "stop" didn't prevent a redirect in this case :( |
|
Wondering if there is anything we can learn from how oauth2-proxy did it with nginx as documented here, with two annotations:
They didn't do any |
Give it a try and see what you get. |
I can't try it until external-auth-server has the proper signin endpoint like oauth2-proxy does. Since external-auth-server supports multiple profiles, we will need additional query params to the signin endpoint, unlike oauth2-proxy where only |
Well I do have an endpoint. Are you using ingress nginx or nginx ingress? Is eas exposed behind ingress nginx? |
I am using ingress-nginx and already got it working using |
I tried below yaml token config:
When I test to send a curl request with header my-jwt-header, external-auth-server throws below errors about json:
Is query_engine jp not supported in yaml format?
BTW, our jwt header doesn't have "bearer" in it. I manually added it in my manual curl test. If the real client sends the jwt header without "bearer", will that be a problem for external-auth-server? Is there a query rule that can check the existence of a header?
The text was updated successfully, but these errors were encountered: