Skip to content

Commit

Permalink
Make "denyUnannotated" config prop only build-time fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik committed Jan 4, 2025
1 parent 72dd7dc commit 1d5b794
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,25 @@ public interface SecurityConfig {
*/
@ConfigDocMapKey("provider-name")
Map<String, String> securityProviderConfig();

/**
* If set to true, access to all methods of beans that have any security annotations on other members will be denied by
* default.
* E.g. if enabled, in the following bean, <code>methodB</code> will be denied.
*
* <pre>
* &#064;ApplicationScoped
* public class A {
* &#064;RolesAllowed("admin")
* public void methodA() {
* ...
* }
* public void methodB() {
* ...
* }
* }
* </pre>
*/
@WithDefault("false")
boolean denyUnannotatedMembers();
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
import io.quarkus.security.runtime.IdentityProviderManagerCreator;
import io.quarkus.security.runtime.QuarkusPermissionSecurityIdentityAugmentor;
import io.quarkus.security.runtime.QuarkusSecurityRolesAllowedConfigBuilder;
import io.quarkus.security.runtime.SecurityBuildTimeConfig;
import io.quarkus.security.runtime.SecurityCheckRecorder;
import io.quarkus.security.runtime.SecurityIdentityAssociation;
import io.quarkus.security.runtime.SecurityIdentityProxy;
Expand Down Expand Up @@ -550,9 +549,8 @@ void transformAdditionalSecuredClassesToMethods(List<AdditionalSecuredClassesBui
*/
@BuildStep
void transformSecurityAnnotations(BuildProducer<AnnotationsTransformerBuildItem> transformers,
List<AdditionalSecuredMethodsBuildItem> additionalSecuredMethods,
SecurityBuildTimeConfig config) {
if (config.denyUnannotated()) {
List<AdditionalSecuredMethodsBuildItem> additionalSecuredMethods) {
if (security.denyUnannotatedMembers()) {
transformers.produce(new AnnotationsTransformerBuildItem(AnnotationTransformation
.forClasses()
.whenClass(new DenyUnannotatedPredicate())
Expand Down Expand Up @@ -747,7 +745,7 @@ MethodSecurityChecks gatherSecurityChecks(
BuildProducer<ClassSecurityCheckStorageBuildItem> classSecurityCheckStorageProducer,
List<RegisterClassSecurityCheckBuildItem> registerClassSecurityCheckBuildItems,
BuildProducer<ReflectiveClassBuildItem> reflectiveClassBuildItemBuildProducer,
List<AdditionalSecurityCheckBuildItem> additionalSecurityChecks, SecurityBuildTimeConfig config,
List<AdditionalSecurityCheckBuildItem> additionalSecurityChecks,
PermissionSecurityChecksBuilderBuildItem permissionSecurityChecksBuilderBuildItem,
BuildProducer<GeneratedClassBuildItem> generatedClassesProducer,
BuildProducer<ReflectiveClassBuildItem> reflectiveClassesProducer) {
Expand All @@ -765,7 +763,7 @@ MethodSecurityChecks gatherSecurityChecks(

IndexView index = beanArchiveBuildItem.getIndex();
Map<MethodInfo, SecurityCheck> securityChecks = gatherSecurityAnnotations(index, configExpSecurityCheckProducer,
additionalSecured.values(), config.denyUnannotated(), recorder, configBuilderProducer,
additionalSecured.values(), security.denyUnannotatedMembers(), recorder, configBuilderProducer,
reflectiveClassBuildItemBuildProducer, rolesAllowedConfigExpResolverBuildItems,
registerClassSecurityCheckBuildItems, classSecurityCheckStorageProducer, hasAdditionalSecAnn,
additionalSecurityAnnotationItems, permissionSecurityChecksBuilderBuildItem.instance,
Expand Down

This file was deleted.

0 comments on commit 1d5b794

Please sign in to comment.