Package com.tnsai.server.security
Record Class AuthConfig
java.lang.Object
java.lang.Record
com.tnsai.server.security.AuthConfig
Authentication configuration for
TnsServer (TNS-302).
When bearerToken() is non-blank, every HTTP request and every WS
upgrade must present Authorization: Bearer <token>; missing or
mismatched tokens are rejected with 401. The token also signs
per-session capability tokens (see
).
invalid reference
CapabilityToken
When bearerToken() is null (or blank), HTTP/WS auth is
disabled. This is permitted only when the server is bound
to loopback (BindPolicy.isLoopback()); the constructor of
TnsServer rejects non-loopback binds without a token. The combination
is the back-compat path for local development.
The default token source for TnsServerMain is the TNSAI_TOKEN
environment variable.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAuthConfig(String bearerToken) Creates an instance of aAuthConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thebearerTokenrecord component.static AuthConfigdisabled()Auth disabled — only valid combined with a loopback bind policy.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanfinal StringtoString()Returns a string representation of this record class.static AuthConfigAuth required with the given Bearer token.
-
Field Details
-
TOKEN_ENV
- See Also:
-
-
Constructor Details
-
AuthConfig
Creates an instance of aAuthConfigrecord class.- Parameters:
bearerToken- the value for thebearerTokenrecord component
-
-
Method Details
-
disabled
Auth disabled — only valid combined with a loopback bind policy. -
withToken
Auth required with the given Bearer token. -
isEnabled
public boolean isEnabled() -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
bearerToken
Returns the value of thebearerTokenrecord component.- Returns:
- the value of the
bearerTokenrecord component
-