Class BasicAuthHttpServiceFilter.Builder<UserInfo>
- java.lang.Object
-
- io.servicetalk.http.utils.auth.BasicAuthHttpServiceFilter.Builder<UserInfo>
-
- Type Parameters:
UserInfo
- a type for authenticated user info object
- Enclosing class:
- BasicAuthHttpServiceFilter<UserInfo>
public static final class BasicAuthHttpServiceFilter.Builder<UserInfo> extends java.lang.Object
A builder for anStreamingHttpServiceFilter
, which filters HTTP requests using RFC7617: The 'Basic' HTTP Authentication Scheme.
-
-
Constructor Summary
Constructors Constructor Description Builder(BasicAuthHttpServiceFilter.CredentialsVerifier<UserInfo> credentialsVerifier, java.lang.String realm)
Creates a new builder for anStreamingHttpServiceFilter
, which filters HTTP requests using RFC7617: The 'Basic' HTTP Authentication Scheme.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamingHttpServiceFilterFactory
buildProxy()
Creates a new instance for proxy service.StreamingHttpServiceFilterFactory
buildServer()
Creates a new instance for non-proxy service.BasicAuthHttpServiceFilter.Builder<UserInfo>
setCharsetUtf8(boolean utf8)
Sets an advice for a user agent to useUTF-8
charset when it generatesuser-id:password
pair.BasicAuthHttpServiceFilter.Builder<UserInfo>
userInfoKey(AsyncContextMap.Key<UserInfo> userInfoKey)
Sets akey
to store a user info object of authenticated user inAsyncContextMap
.
-
-
-
Constructor Detail
-
Builder
public Builder(BasicAuthHttpServiceFilter.CredentialsVerifier<UserInfo> credentialsVerifier, java.lang.String realm)
Creates a new builder for anStreamingHttpServiceFilter
, which filters HTTP requests using RFC7617: The 'Basic' HTTP Authentication Scheme.It accepts credentials as
user-id:password
pairs, encoded usingBase64
forAuthorization
orProxy-Authorization
header values. Use of the formatuser:password
in theuserinfo
field is deprecated by RFC3986.User info object of authenticated user could be stored in
AsyncContextMap
, ifAsyncContextMap.Key
was configured viauserInfoKey(AsyncContextMap.Key)
.Note: This scheme is not considered to be a secure method of user authentication unless used in conjunction with some external secure system such as TLS (Transport Layer Security, [RFC5246]), as the
user-id
andpassword
are passed over the network as cleartext.- Parameters:
credentialsVerifier
- aBasicAuthHttpServiceFilter.CredentialsVerifier
foruser-id
andpasswords
pairrealm
- a protection space (realm)
-
-
Method Detail
-
userInfoKey
public BasicAuthHttpServiceFilter.Builder<UserInfo> userInfoKey(AsyncContextMap.Key<UserInfo> userInfoKey)
Sets akey
to store a user info object of authenticated user inAsyncContextMap
.- Parameters:
userInfoKey
- a key to store a user info object inAsyncContextMap
- Returns:
this
-
setCharsetUtf8
public BasicAuthHttpServiceFilter.Builder<UserInfo> setCharsetUtf8(boolean utf8)
Sets an advice for a user agent to useUTF-8
charset when it generatesuser-id:password
pair.It will result in adding an optional charset="UTF-8" parameter for an authenticate header.
- Parameters:
utf8
- iftrue
, an optionalcharset="UTF-8"
parameter will be added for an authenticate header- Returns:
this
-
buildServer
public StreamingHttpServiceFilterFactory buildServer()
Creates a new instance for non-proxy service.It will use the following constants to handle authentication:
Response status code, authenticate and authorization headers for non-proxy Basic auth Response status code 401 (Unauthorized) Authenticate header WWW-Authenticate Authorization header Authorization - Returns:
- a new
BasicAuthHttpServiceFilter.Builder
-
buildProxy
public StreamingHttpServiceFilterFactory buildProxy()
Creates a new instance for proxy service.It will use the following constants to handle authentication:
Response status code, authenticate and authorization headers for proxy Basic auth Response status code 407 (Proxy Authentication Required) Authenticate header Proxy-Authenticate Authorization header Proxy-Authorization - Returns:
- a new
StreamingHttpServiceFilterFactory
-
-