我在使用@PreAuthorize注释时遇到了问题.即使我的用户不拥有所请求的角色,我的安全方法也会被执行.
我的控制器:
@Controller
@RequestMapping("/stats/distributions")
public class DistributionStatsController {
@PreAuthorize("hasAnyAuthority('AK_LOCAL_DIST_INT', 'AK_ADMIN')")
@RequestMapping(method = RequestMethod.POST, consumes = "application/json; charset=utf-8",
produces = "application/json; charset=utf-8")
public @ResponseBody List<DistributionStatsResource> filter(@RequestBody DistributionStatsResource resource,
@RequestParam(required = false, value = "documentId") Long documentId,
@RequestParam(required = false, value = "distStatus") EnumDistributionStatus distributionStatus,
Pageable pageable, HttpServletRequest request) {
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的spring安全配置:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
/** Defines the AuthenticationManager/providers. */
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(preAuthenticatedAuthenticationProvider());
}
@Override …Run Code Online (Sandbox Code Playgroud) 尝试从我的Maven原型生成项目时遇到问题。当没有解析javascript文件时,一切都很好(即,排除在archetype-metadata.xml文件之外)。但是我需要${MyProject}在一些js文件中插入变量,以免排除项目js文件。
这是我的原型配置:(archetype-metadata.xml文件)
<!-- Project Web Content -->
<fileSet filtered="true" packaged="false" encoding="UTF-8">
<directory>src/main/webapp</directory>
<excludes>
<exclude>js/libs/**/*</exclude>
<exclude>js/angular-mock/**/*</exclude>
<exclude>template/**/*</exclude>
<exclude>views/**/*</exclude>
<exclude>img/**/*</exclude>
<exclude>font/**/*</exclude>
<exclude>icones/**/*</exclude>
<exclude>css/**/*</exclude>
</excludes>
</fileSet>
Run Code Online (Sandbox Code Playgroud)
这是我在3个测试用例中遇到的不同错误(我尝试排除在archetype-metadata.xml某些出现错误的文件中):
Unable to create project from archetype [com.mypackage.archetypes:ngwis-project:2.0-SNAPSHOT]
org.apache.maven.archetype.exception.ArchetypeGenerationFailure: Error merging velocity templates: Encountered "}" at line 14, column 25 of archetype-resources/__rootArtifactId__Web/src/main/webapp/js/__rootArtifactId__/application.js
Was expecting one of:
"[" ...
"{" ...
<STRING_LITERAL> ...
"true" ...
"false" ...
<INTEGER_LITERAL> ...
<FLOATING_POINT_LITERAL> ...
<IDENTIFIER> ...
"{" ...
Unable to create project from …Run Code Online (Sandbox Code Playgroud)