Skip to content
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

Add support for Spring Security's @Secured #5225

Merged
merged 1 commit into from
Nov 21, 2019

Conversation

aureamunoz
Copy link
Member

This PR contains a new extension spring-security implementing @Secured annotation.
It's based on #5074 and is a draft.
I let you, @geoand and @michalszynkiewicz , take a look and forward to others if needed.
Thank you

@gsmet
Copy link
Member

gsmet commented Nov 5, 2019

@aureamunoz quick question, I haven't looked at the implementation: does it support the EL Spring Security has (things such as hasRole() and so on)? I suppose not. I wonder what would be necessary for us to support that because it's very useful in practice.

@gsmet
Copy link
Member

gsmet commented Nov 5, 2019

BTW, I should have started by that: it's an exciting new addition.

@geoand
Copy link
Contributor

geoand commented Nov 5, 2019

Nice work!

To answer your question @gsmet, the stuff you describe I am pretty sure is covered by Spring's @PreAuthorize which I'll probably be picking up soon

@netodevel
Copy link
Contributor

@aureamunoz,

Suggestion:

I don't know if it's possible, but it would be nice to have security configuration support.
Something like:

http
.authorizeRequests()
.antMatchers("/hello/**").allowAll()

@geoand
Copy link
Contributor

geoand commented Nov 8, 2019

@netodevel we aren't planning to support that style of configuration at this time. That doesn't mean that we won't in the future, but just that it's not in the immediate plans.

@netodevel
Copy link
Contributor

@geoand,
Ok, I'll follow this issue to understand and try to contribute in the future.
Thanks for answering me.

@geoand
Copy link
Contributor

geoand commented Nov 8, 2019

You are welcome!

@geoand
Copy link
Contributor

geoand commented Nov 9, 2019

@michalszynkiewicz @aureamunoz what is the status of #5074?

Is there anything I can do to help?

@michalszynkiewicz
Copy link
Member

@geoand imo done, Stuart asked if I can use index instead of looping throug all classes but AFAIK I can't

@geoand
Copy link
Contributor

geoand commented Nov 9, 2019

Which part of your PR is the code in question @michalszynkiewicz ?

I can take a look on Monday if you like

@michalszynkiewicz
Copy link
Member

https://github.com/quarkusio/quarkus/pull/5074/files#diff-36e991a830b10f10b19a4360212eebcaR194

@geoand
Copy link
Contributor

geoand commented Nov 11, 2019

I'll be looking at #5074 today

@geoand
Copy link
Contributor

geoand commented Nov 11, 2019

@michalszynkiewicz Nice work!

I was thinking of implementing this in a slightly different manner however. The basic premise that I have in mind is that methods need to be "mapped" to a SecurityCheck.
With that in mind things like Spring's @Secured would not need to use the annotation transformer, the extension could just map methods to the appropriate RolesAllowed check.

There are probably a few mechanics involved to make this work properly but I will start from your PR and build on it to incorporate the solution I have in mind which I think should turn out to be simpler and avoid the need to go over all classes in the index.

@geoand
Copy link
Contributor

geoand commented Nov 11, 2019

I'm going to try to come up with a way to do this that will also allow for the types of SecurityChecks that will be needed for Spring's @PreAuthorize

geoand added a commit to geoand/quarkus that referenced this pull request Nov 14, 2019
This is done by allowing the registration of arbitrary
SecurityCheck implementations.
Furthermore the use of the AnnotationStore is hidden so as
to not give the impression that it's a feature that magically
makes security annotations work

This change paves the way for quarkusio#5225 and more related improvements
in the future
@geoand
Copy link
Contributor

geoand commented Nov 18, 2019

I just updated the PR to align with the changes made in the core Quarkus security

@geoand
Copy link
Contributor

geoand commented Nov 18, 2019

One thing that is missing is an integration test that will ensure this works in native mode

@michalszynkiewicz
Copy link
Member

@geoand maybe add it to the main module of the integration tests? It already has security enabled

@geoand
Copy link
Contributor

geoand commented Nov 18, 2019

@michalszynkiewicz we don't want to add Spring Security to the main module because that one should not depend on any Spring things.
We could probably just add it to the Spring Web integration test in order to avoid having a completely new integration test that will take up a lot of time.
The reason I want an integration test for Spring security is that there could perhaps be problems with the Spring Security artifact that will only show up in native mode - and that might require maven exclusions or GraalVM substitutions.

@michalszynkiewicz
Copy link
Member

michalszynkiewicz commented Nov 18, 2019

@geoand if you ask me, we should have native tests for all the stuff. OTOH, the native test modules are really costly.
+1 from me for adding it to spring web integration tests if we have a module for them.

@geoand
Copy link
Contributor

geoand commented Nov 18, 2019

We do have a Spring Web integration test module so I propose @aureamunoz add them there

@aureamunoz
Copy link
Member Author

We do have a Spring Web integration test module so I propose @aureamunoz add them there

Yes, of course. It's what I'm doing, sorry for not saying nothing until now 😏

ia3andy pushed a commit to dmlloyd/quarkus that referenced this pull request Nov 19, 2019
This is done by allowing the registration of arbitrary
SecurityCheck implementations.
Furthermore the use of the AnnotationStore is hidden so as
to not give the impression that it's a feature that magically
makes security annotations work

This change paves the way for quarkusio#5225 and more related improvements
in the future
@geoand
Copy link
Contributor

geoand commented Nov 19, 2019

@aureamunoz can you please squash the second commit?
I don't think that in this case it makes sense to have a second one.
If you add a guide however, then that would make an excellent second commit

import org.jboss.jandex.MethodInfo;
import org.springframework.security.access.annotation.Secured;

public class SpringSecurityTransformerUtils {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this class needed? I don't think it's used, correct?

Co-authored-by: geoand <geoand@gmail.com>
@gsmet gsmet dismissed their stale review November 20, 2019 22:02

Haven't checked the logic itself but the things I noted were addressed.

@michalszynkiewicz
Copy link
Member

It wouldn't hurt to have a test for the newly added check but that's not a big issue.
LGTM

@geoand
Copy link
Contributor

geoand commented Nov 21, 2019

It wouldn't hurt to have a test for the newly added check but that's not a big issue.
LGTM

There is one test, indeed there could have been more :)

@geoand
Copy link
Contributor

geoand commented Nov 21, 2019

Thanks for all the work @aureamunoz and for all the support @michalszynkiewicz !

@geoand geoand merged commit 5de59a5 into quarkusio:master Nov 21, 2019
@michalszynkiewicz
Copy link
Member

michalszynkiewicz commented Nov 21, 2019

Thanks for all the work @aureamunoz !

👍 good job!

It wouldn't hurt to have a test for the newly added check but that's not a big issue.
LGTM

There is one test, indeed there could have been more :)

sorry, I missed that.

@geoand
Copy link
Contributor

geoand commented Nov 21, 2019

sorry, I missed that.

No worries!
Thanks again for your help!

Simulant87 pushed a commit to Simulant87/quarkus that referenced this pull request Nov 23, 2019
This is done by allowing the registration of arbitrary
SecurityCheck implementations.
Furthermore the use of the AnnotationStore is hidden so as
to not give the impression that it's a feature that magically
makes security annotations work

This change paves the way for quarkusio#5225 and more related improvements
in the future
Simulant87 pushed a commit to Simulant87/quarkus that referenced this pull request Nov 23, 2019
This is done by allowing the registration of arbitrary
SecurityCheck implementations.
Furthermore the use of the AnnotationStore is hidden so as
to not give the impression that it's a feature that magically
makes security annotations work

This change paves the way for quarkusio#5225 and more related improvements
in the future
@gsmet gsmet added this to the 1.1.0 milestone Nov 24, 2019
aureamunoz added a commit to aureamunoz/quarkus that referenced this pull request Nov 25, 2019
gsmet pushed a commit to aureamunoz/quarkus that referenced this pull request Nov 25, 2019
@paulrobinson paulrobinson mentioned this pull request Nov 26, 2019
2 tasks
mmusgrov pushed a commit to mmusgrov/quarkus that referenced this pull request Dec 13, 2019
This is done by allowing the registration of arbitrary
SecurityCheck implementations.
Furthermore the use of the AnnotationStore is hidden so as
to not give the impression that it's a feature that magically
makes security annotations work

This change paves the way for quarkusio#5225 and more related improvements
in the future
mmusgrov pushed a commit to mmusgrov/quarkus that referenced this pull request Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants