diff --git a/src/main/java/io/wwan13/wintersecurity/config/EnableWebSecurity.java b/src/main/java/io/wwan13/wintersecurity/config/EnableWebSecurity.java index 52234a6..f5ae16e 100644 --- a/src/main/java/io/wwan13/wintersecurity/config/EnableWebSecurity.java +++ b/src/main/java/io/wwan13/wintersecurity/config/EnableWebSecurity.java @@ -29,7 +29,8 @@ AuthProcessorRegistrar.class, JwtPropertiesRegistrar.class, JwtConfiguration.class, - PasswordEncoderConfiguration.class + PasswordEncoderConfiguration.class, + TargetAnnotationsRegistrar.class }) public @interface EnableWebSecurity { } diff --git a/src/main/java/io/wwan13/wintersecurity/config/TargetAnnotationsRegistrar.java b/src/main/java/io/wwan13/wintersecurity/config/TargetAnnotationsRegistrar.java new file mode 100644 index 0000000..ebfbdf1 --- /dev/null +++ b/src/main/java/io/wwan13/wintersecurity/config/TargetAnnotationsRegistrar.java @@ -0,0 +1,38 @@ +/* + * Copyright 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.wwan13.wintersecurity.config; + +import io.wwan13.wintersecurity.resolve.TargetAnnotations; +import io.wwan13.wintersecurity.resolve.support.TargetAnnotationsApplier; +import io.wwan13.wintersecurity.resolve.support.TargetAnnotationsRegistry; +import org.springframework.context.annotation.Bean; + +public class TargetAnnotationsRegistrar { + + private final WebSecurityConfigurer webSecurityConfigurer; + + public TargetAnnotationsRegistrar(WebSecurityConfigurer webSecurityConfigurer) { + this.webSecurityConfigurer = webSecurityConfigurer; + } + + @Bean + public TargetAnnotations targetAnnotations() { + TargetAnnotationsRegistry registry = new TargetAnnotationsRegistry(); + webSecurityConfigurer.registerResolveTargets(registry); + return TargetAnnotationsApplier.apply(registry); + } +} diff --git a/src/main/java/io/wwan13/wintersecurity/config/WebSecurityConfigurer.java b/src/main/java/io/wwan13/wintersecurity/config/WebSecurityConfigurer.java index 33578d1..7fc87cc 100644 --- a/src/main/java/io/wwan13/wintersecurity/config/WebSecurityConfigurer.java +++ b/src/main/java/io/wwan13/wintersecurity/config/WebSecurityConfigurer.java @@ -18,9 +18,13 @@ import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestRegistry; import io.wwan13.wintersecurity.jwt.support.JwtPropertiesRegistry; +import io.wwan13.wintersecurity.resolve.support.TargetAnnotationsRegistry; public interface WebSecurityConfigurer { void registerAuthPatterns(AuthorizedRequestRegistry registry); + void configureJwt(JwtPropertiesRegistry registry); + + void registerResolveTargets(TargetAnnotationsRegistry registry); }