-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[Java][Spring][1975] Add OAuth2 Preauthorize annotations based on scope #5398
[Java][Spring][1975] Add OAuth2 Preauthorize annotations based on scope #5398
Conversation
07b4fb8
to
c857e4d
Compare
I think this doesn't work if there's multiple securities defined for an operation (eg. Oauth + basic). |
c857e4d
to
0fdafc2
Compare
@cbornet I just tested with an OpenAPI spec that has both OAuth2 and Basic, and seems to be working, because it has |
What I mean is that an endpoint that has both basic and oauth should be accessible by basic OR oauth. Here I think if you try to access by basic auth, the pre-authorization will fail and you will be rejected. |
Ah, got it. So it should generate |
@cbornet good catch. I think such a case rarely occurs (based on my experience dealing with issues reported to this repo). We can document it as a known issue for the time being and work on it when there's a demand to fix it. |
I just stumbled here trying to find Anything I can do to help? |
Hi @Walliee , sorry I didn't have much time lately, your help would be greatly appreciated. Firstly, not sure if the tests are failing because of the use case @cbornet mentioned, so that's pending some investigation (though @wing328 mentioned that we can ignore that use case for now, but we still need to fix the tests). One other thing is this change would fail for people that don't use Spring Security because it imports a class from there, so maybe this should be a configuration that people can turn on (like addPreAuthorize = true). Thanks |
Yes; of course. The pointers you gave make sense. Thanks! @nhomble and I looked at this briefly today and looks like we can handle bearer auth too. We’ll hopefully have a PR out tomorrow. |
Awesome stuff @ersinciftci, we are still polishing a little bit (and I need to regen the samples), but here is a sneak peak |
@nhomble looks great! |
I would love opinions on this thanks! |
@nhomble looks much better than this one, thanks! (I'm closing this one) |
Fixes #1975
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.