jakartaee / jakartaee/security
Provides a fluent API to apply security rules on Http resources
- Dominant language
- Java
- Stars
- 66
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
Currently when applying securities we have to use annotations(`RolesAllow`, etc) or configure them in the web.xml(for Servlet based application), hope there is an approach to declare a CDI bean to build the security rules like Spring Security, eg.
```
class SecurityConfig{
@Bean
SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http,
JwtTokenProvider tokenProvider,
ReactiveAuthenticationManager reactiveAuthenticationManager) {
final String PATH_POSTS = "/posts/**";
return http.csrf(ServerHttpSecurity.CsrfSpec::disable)
.httpBasic(ServerHttpSecurity.HttpBasicSpec::disable)
.authenticationManager(reactiveAuthenticationManager)
.securityContextRepository(NoOpServerSecurityContextRepository.getInstance())
.authorizeExchange(it -> it
.pathMatchers(HttpMethod.GET, PATH_POSTS).permitAll()
.pathMatchers(HttpMethod.DELETE, PATH_POSTS).hasRole("ADMIN")
.pathMatchers(PATH_POSTS).authenticated()
.pathMatchers("/me").authenticated()
.pathMatchers("/users/{user}/**").access(this::currentUserMatchesPath)
.anyExchange().permitAll()
)
.addFilterAt(new JwtTokenAuthenticationFilter(tokenProvider), SecurityWebFiltersOrder.HTTP_BASIC)
.build();
}
}
```
Contributor guide
Research direction
Start by reviewing the existing RolesAllow annotations and Servlet web.xml security configuration, then compare them with the requested CDI-based fluent configuration. The work is done when Jakarta Security supports declaring HTTP resource rules through such an API and its behavior is covered by appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authorization, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100