use of com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAttestationResultEndpointFilter in project webauthn4j-spring-security by webauthn4j.
the class WebSecurityConfig method configure.
/**
* Configure SecurityFilterChain
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
// WebAuthn Config
http.apply(WebAuthnLoginConfigurer.webAuthnLogin()).attestationOptionsEndpoint().rp().name("WebAuthn4J Spring Security Sample").and().pubKeyCredParams(new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256), new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.RS1)).extensions().entry("example.extension", "test").and().assertionOptionsEndpoint().extensions().entry("example.extension", "test").and();
FidoServerAttestationOptionsEndpointFilter fidoServerAttestationOptionsEndpointFilter = new FidoServerAttestationOptionsEndpointFilter(objectConverter, attestationOptionsProvider, challengeRepository);
FidoServerAttestationResultEndpointFilter fidoServerAttestationResultEndpointFilter = new FidoServerAttestationResultEndpointFilter(objectConverter, userDetailsManager, webAuthnAuthenticatorManager, webAuthnRegistrationRequestValidator);
fidoServerAttestationResultEndpointFilter.setUsernameNotFoundHandler(new SampleUsernameNotFoundHandler(userDetailsManager));
FidoServerAssertionOptionsEndpointFilter fidoServerAssertionOptionsEndpointFilter = new FidoServerAssertionOptionsEndpointFilter(objectConverter, assertionOptionsProvider, challengeRepository);
FidoServerAssertionResultEndpointFilter fidoServerAssertionResultEndpointFilter = new FidoServerAssertionResultEndpointFilter(objectConverter, serverPropertyProvider);
fidoServerAssertionResultEndpointFilter.setAuthenticationManager(authenticationManagerBean());
http.addFilterAfter(fidoServerAttestationOptionsEndpointFilter, SessionManagementFilter.class);
http.addFilterAfter(fidoServerAttestationResultEndpointFilter, SessionManagementFilter.class);
http.addFilterAfter(fidoServerAssertionOptionsEndpointFilter, SessionManagementFilter.class);
http.addFilterAfter(fidoServerAssertionResultEndpointFilter, SessionManagementFilter.class);
// Authorization
http.authorizeRequests().mvcMatchers("/").permitAll().mvcMatchers("/api/auth/status").permitAll().mvcMatchers(HttpMethod.GET, "/login").permitAll().mvcMatchers(HttpMethod.POST, "/api/profile").permitAll().mvcMatchers("/health/**").permitAll().mvcMatchers("/info/**").permitAll().mvcMatchers("/h2-console/**").denyAll().mvcMatchers("/api/admin/**").hasRole(ADMIN_ROLE).anyRequest().fullyAuthenticated();
// TODO:
http.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
http.csrf().ignoringAntMatchers("/webauthn/**");
}
Aggregations