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

@EndpointDisabled can be used on methods #40433

Open
farnetto opened this issue May 3, 2024 · 9 comments
Open

@EndpointDisabled can be used on methods #40433

farnetto opened this issue May 3, 2024 · 9 comments
Labels

Comments

@farnetto
Copy link

farnetto commented May 3, 2024

Description

@EndpointDisabled currently "provides the ability to conditionally enable [i.e. disable] a JAX-RS Resource class at runtime based on the value of a property."

I would like to use this annotation or a similar one to disable specific methods (in Rest Data Panache https://quarkus.io/guides/rest-data-panache#using-a-runtime-property) at runtime based on a property.

My use case is, I use the state-changing PUT, POST and DELETE methods in tests, but want to disable them for security reasons in production and still be able to use the GET methods in production to query the data.

Implementation ideas

Currently the annotation is @Target({ElementType.TYPE}) but should ideally be also ElementType.METHOD.

@farnetto farnetto added the kind/enhancement New feature or request label May 3, 2024
@farnetto
Copy link
Author

farnetto commented May 3, 2024

Alternatively one could extend the exposed attribute @MethodProperties to support a runtime property the way @EndpointDisabled supports a runtime property.

@mschorsch
Copy link

mschorsch commented May 10, 2024

As an alternative you could use build profiles e.g.

   @DELETE
   @IfBuildProfile("test")
    public void deleteSomething () {
        // ...
    }

@farnetto
Copy link
Author

but I want a toggle for runtime not build time...

@gsmet
Copy link
Member

gsmet commented May 13, 2024

I think the requirement makes sense. I also wonder if it could be a good first issue if someone from the team provided a bit more details about how it could be implemented.

I would expect most of the changes to be done in EndpointIndexer.
My main question is if we should adjust the current isDisabledCreator to target a method (and then default to the behavior of the enclosing class) or if we add another Function to handle the methods.

@FroMage @geoand WDYT?

@geoand
Copy link
Contributor

geoand commented May 13, 2024

What OP is asking for though is to have the methods disabled with a runtime configuration property.

I don't remember how the annotation works, so I would have to look at the code again

@FroMage
Copy link
Member

FroMage commented May 14, 2024

Makes sense to extend its granularity from class to methods, yes.

@farnetto
Copy link
Author

I'd love to try implementing it myself - as a first issue as @gsmet says.

@geoand
Copy link
Contributor

geoand commented May 14, 2024

Feel free!

@geoand
Copy link
Contributor

geoand commented May 14, 2024

My main question is if we should adjust the current isDisabledCreator to target a method (and then default to the behavior of the enclosing class) or if we add another Function to handle the methods

I think adjusting the existing one is probably better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants