Skip to content

Commit

Permalink
Merge pull request #45366 from michalvavrik/feature/move-deny-unannot…
Browse files Browse the repository at this point in the history
…ated-to-buildtime-fixed

Drop `@ConfigMapping` security interface with `BUILD_AND_RUN_TIME_FIXED` as we don't need `denyUnannotated` in the runtime config phase
  • Loading branch information
gastaldi authored Jan 5, 2025
2 parents 9512889 + 1d5b794 commit 0e9d883
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 0e9d883

Please sign in to comment.