Skip to content

Commit 58a0fed

Browse files
committed
feat : Autoconfiguration for ArgumentResolvers
1 parent b5d599f commit 58a0fed

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.wwan13.wintersecurity.config;
18+
19+
import io.wwan13.wintersecurity.resolve.RolesResolver;
20+
import io.wwan13.wintersecurity.resolve.SubjectResolver;
21+
import io.wwan13.wintersecurity.resolve.TargetAnnotations;
22+
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
23+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
24+
25+
import java.util.List;
26+
27+
public class ArgumentResolversRegistrar implements WebMvcConfigurer {
28+
29+
private final TargetAnnotations targetAnnotations;
30+
31+
public ArgumentResolversRegistrar(TargetAnnotations targetAnnotations) {
32+
this.targetAnnotations = targetAnnotations;
33+
}
34+
35+
@Override
36+
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
37+
SubjectResolver subjectResolver = new SubjectResolver(targetAnnotations);
38+
resolvers.add(subjectResolver);
39+
40+
RolesResolver rolesResolver = new RolesResolver(targetAnnotations);
41+
resolvers.add(rolesResolver);
42+
}
43+
}

src/main/java/io/wwan13/wintersecurity/config/EnableSecureRequest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
AuthConfiguration.class,
3333
AuthProcessorRegistrar.class,
3434
TargetAnnotationsRegistrar.class,
35+
ArgumentResolversRegistrar.class,
3536
SecretKeyRegistrar.class
3637
})
3738
public @interface EnableSecureRequest {

0 commit comments

Comments
 (0)