Skip to content

Commit

Permalink
Merge pull request #86 from ssylver93/feature/WFPREV-34_3
Browse files Browse the repository at this point in the history
Test sonar
  • Loading branch information
ssylver93 authored Sep 30, 2024
2 parents 21afc0b + c432d75 commit ddea582
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sonarscan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
java-version: 17
distribution: 'adopt'
- name: SonarCloud Scan
- name: SonarCloud Scan
run: |
export MAVEN_OPTS="-Xmx10000m"
export NODE_OPTIONS="--max-old-space-size=4096"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,81 +20,81 @@
import jakarta.servlet.http.HttpServletRequest;

/**
* Default security configuration.
* Assumes all secure endpoints, bearer token, using existing Webade Authentication
* Default security configuration. Assumes all secure endpoints, bearer token,
* using existing Webade Authentication
*/

@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Value("${security.oauth.clientId}")
private String oauthClientId;

@Value("${security.oauth.clientSecret}")
private String oauthClientSecret;

@Value("${security.oauth.checkTokenUrl}")
private String oauthCheckTokenUrl;

@Value("${security.oauth.authTokenUrl}")
private String authTokenUrl;

@Bean
AuthenticationEntryPoint authenticationEntryPoint() {
BasicAuthenticationEntryPoint result;

result = new BasicAuthenticationEntryPoint();
result.setRealmName("wfim-incidents-api");

return result;
}

@Bean
public TokenService tokenServiceImpl() {
return new TokenServiceImpl(
oauthClientId,
oauthClientSecret,
oauthCheckTokenUrl,
authTokenUrl);
}

@Bean
public AuthenticationProvider authenticationProvider() {
return new WebadeOauth2AuthenticationProvider(tokenServiceImpl(), "WFIM.*");
}

@Bean
public AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver() {
return new AuthenticationManagerResolver<HttpServletRequest>() {
@Override
public AuthenticationManager resolve(HttpServletRequest httpServletRequest) {
return new AuthenticationManager() {
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
return authenticationProvider().authenticate(authentication);
}};
}};
}

@Value("${security.oauth.clientId}")
private String oauthClientId;

@Value("${security.oauth.clientSecret}")
private String oauthClientSecret;

@Value("${security.oauth.checkTokenUrl}")
private String oauthCheckTokenUrl;

@Value("${security.oauth.authTokenUrl}")
private String authTokenUrl;

@Bean
AuthenticationEntryPoint authenticationEntryPoint() {
BasicAuthenticationEntryPoint result;

result = new BasicAuthenticationEntryPoint();
result.setRealmName("wfim-incidents-api");

return result;
}

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {

http.csrf().disable();

http.authorizeHttpRequests().anyRequest().permitAll();

// http
// .oauth2ResourceServer(oauth2 -> oauth2
// .authenticationManagerResolver(authenticationManagerResolver())
// )
// .httpBasic().and()
// .authorizeHttpRequests((authorize) -> authorize
// .anyRequest().authenticated()
// )
// .exceptionHandling()
// .authenticationEntryPoint(authenticationEntryPoint());

return http.build();
}
public TokenService tokenServiceImpl() {
return new TokenServiceImpl(
oauthClientId,
oauthClientSecret,
oauthCheckTokenUrl,
authTokenUrl);
}

@Bean
public AuthenticationProvider authenticationProvider() {
return new WebadeOauth2AuthenticationProvider(tokenServiceImpl(), "WFIM.*");
}

@Bean
public AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver() {
return new AuthenticationManagerResolver<HttpServletRequest>() {
@Override
public AuthenticationManager resolve(HttpServletRequest httpServletRequest) {
return new AuthenticationManager() {
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
return authenticationProvider().authenticate(authentication);
}
};
}
};
}

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {

http.csrf().disable();

http
.oauth2ResourceServer(oauth2 -> oauth2
.authenticationManagerResolver(authenticationManagerResolver())
)
.httpBasic().and()
.authorizeHttpRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.exceptionHandling()
.authenticationEntryPoint(authenticationEntryPoint());

return http.build();
}

}

0 comments on commit ddea582

Please sign in to comment.