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.ObjectA 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 StreamingHttpServiceFilterFactorybuildProxy()Creates a new instance for proxy service.StreamingHttpServiceFilterFactorybuildServer()Creates a new instance for non-proxy service.BasicAuthHttpServiceFilter.Builder<UserInfo>setCharsetUtf8(boolean utf8)Sets an advice for a user agent to useUTF-8charset when it generatesuser-id:passwordpair.BasicAuthHttpServiceFilter.Builder<UserInfo>userInfoKey(AsyncContextMap.Key<UserInfo> userInfoKey)Sets akeyto 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:passwordpairs, encoded usingBase64forAuthorizationorProxy-Authorizationheader values. Use of the formatuser:passwordin theuserinfofield is deprecated by RFC3986.User info object of authenticated user could be stored in
AsyncContextMap, ifAsyncContextMap.Keywas 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-idandpasswordare passed over the network as cleartext.- Parameters:
credentialsVerifier- aBasicAuthHttpServiceFilter.CredentialsVerifierforuser-idandpasswordspairrealm- a protection space (realm)
-
-
Method Detail
-
userInfoKey
public BasicAuthHttpServiceFilter.Builder<UserInfo> userInfoKey(AsyncContextMap.Key<UserInfo> userInfoKey)
Sets akeyto 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-8charset when it generatesuser-id:passwordpair.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
-
-