Skip to content

Commit

Permalink
feat : Register TargetAnnotations as spring bean
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed May 27, 2024
1 parent 51937cf commit fa3686b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
AuthProcessorRegistrar.class,
JwtPropertiesRegistrar.class,
JwtConfiguration.class,
PasswordEncoderConfiguration.class
PasswordEncoderConfiguration.class,
TargetAnnotationsRegistrar.class
})
public @interface EnableWebSecurity {
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit fa3686b

Please sign in to comment.