Package org.springframework.security.web.server.authentication

# Class AnonymousAuthenticationWebFilter

java.lang.Object
org.springframework.security.web.server.authentication.AnonymousAuthenticationWebFilter

All Implemented Interfaces:
  `org.springframework.web.server.WebFilter`

public class AnonymousAuthenticationWebFilter extends Object implements org.springframework.web.server.WebFilter
Detects if there is no `Authentication` object in the `ReactiveSecurityContextHolder`, and populates it with one if needed.

Since:
  5.2.0

## Constructor Summary

Constructors
Constructor
Description
`AnonymousAuthenticationWebFilter(String key)`
Creates a filter with a principal named "anonymousUser" and the single authority "ROLE_ANONYMOUS".
`AnonymousAuthenticationWebFilter(String key, Object principal, List<org.springframework.security.core.GrantedAuthority> authorities)`

## Method Summary

Modifier and Type
Method
Description
`protected org.springframework.security.core.Authentication`
`createAuthentication(org.springframework.web.server.ServerWebExchange exchange)`
`reactor.core.publisher.Mono<Void>`
`filter(org.springframework.web.server.ServerWebExchange exchange, org.springframework.web.server.WebFilterChain chain)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AnonymousAuthenticationWebFilter

public AnonymousAuthenticationWebFilter(String key)
Creates a filter with a principal named "anonymousUser" and the single authority "ROLE_ANONYMOUS".

Parameters:
  `key` - the key to identify tokens created by this filter

### AnonymousAuthenticationWebFilter

public AnonymousAuthenticationWebFilter(String key, Object principal, List<org.springframework.security.core.GrantedAuthority> authorities)

Parameters:
  `key` - key the key to identify tokens created by this filter
  `principal` - the principal which will be used to represent anonymous users
  `authorities` - the authority list for anonymous users

## Method Details

### filter

public reactor.core.publisher.Mono<Void> filter(org.springframework.web.server.ServerWebExchange exchange, org.springframework.web.server.WebFilterChain chain)

Specified by:
  `filter` in interface `org.springframework.web.server.WebFilter`

### createAuthentication

protected org.springframework.security.core.Authentication createAuthentication(org.springframework.web.server.ServerWebExchange exchange)