Record Class AuthResult

java.lang.Object
java.lang.Record
google.registry.request.auth.AuthResult
Record Components:
userAuthInfo - Information about the authenticated user, if there is one.
appServiceAccount - Service account email of the authenticated app, if there is one. This will be logged upon successful login.

public record AuthResult(AuthSettings.AuthLevel authLevel, Optional<UserAuthInfo> userAuthInfo, Optional<String> appServiceAccount) extends Record
Results of authentication for a given HTTP request, as emitted by an AuthenticationMechanism.
  • Field Details

    • NOT_AUTHENTICATED

      public static final AuthResult NOT_AUTHENTICATED
      No authentication was made.

      In the authentication step, this means that none of the configured authentication methods were able to authenticate the user. But the authorization settings may be such that it's perfectly fine not to be authenticated. The RequestAuthenticator.authorize(google.registry.request.auth.AuthSettings, jakarta.servlet.http.HttpServletRequest) method returns NOT_AUTHENTICATED in this case, as opposed to absent() if authentication failed and was required. So as a return from an authorization check, this can be treated as a success.

  • Constructor Details

  • Method Details

    • isAuthenticated

      public boolean isAuthenticated()
    • userIdForLogging

      public String userIdForLogging()
    • createApp

      public static AuthResult createApp(String email)
    • createUser

      public static AuthResult createUser(UserAuthInfo userAuthInfo)
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • authLevel

      public AuthSettings.AuthLevel authLevel()
      Returns the value of the authLevel record component.
      Returns:
      the value of the authLevel record component
    • userAuthInfo

      public Optional<UserAuthInfo> userAuthInfo()
      Returns the value of the userAuthInfo record component.
      Returns:
      the value of the userAuthInfo record component
    • appServiceAccount

      public Optional<String> appServiceAccount()
      Returns the value of the appServiceAccount record component.
      Returns:
      the value of the appServiceAccount record component