Record Class OahOAuth

java.lang.Object
java.lang.Record
com.github.catomat0.oauthhelper.oauth.OahOAuth

public record OahOAuth(OahStateService state, OahAuthorizeUrlBuilder authorize, OahLoginService login) extends Record
OAuth 관련 서비스 3개를 묶은 파사드.

컨트롤러에서 개별 빈 3개 대신 이 하나만 주입받아 사용:


 public AuthController(OahOAuth oauth) { this.oauth = oauth; }

 @GetMapping("/authorize")
 public void authorize(...) {
     OahAuthorizeParams p = oauth.state().issue("kakao");
     String url = oauth.authorize().build("kakao", p);
     // ...
 }
 @GetMapping("/callback")
 public ResponseEntity<?> callback(...) {
     String verifier = oauth.state().validateAndConsume(state, provider);
     OahUserInfo info = oauth.login().fetchUserInfo(provider, code, verifier);
     // ...
 }
 

Redis 세팅 안 되어 있으면 state 빈이 없어 이 파사드도 자동 등록 안 됨 — 그 경우 OahAuthorizeUrlBuilder / OahLoginService 를 직접 주입.

  • Constructor Details

    • OahOAuth

      public OahOAuth(OahStateService state, OahAuthorizeUrlBuilder authorize, OahLoginService login)
      Creates an instance of a OahOAuth record class.
      Parameters:
      state - the value for the state record component
      authorize - the value for the authorize record component
      login - the value for the login record component
  • Method Details

    • 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.
    • state

      public OahStateService state()
      Returns the value of the state record component.
      Returns:
      the value of the state record component
    • authorize

      public OahAuthorizeUrlBuilder authorize()
      Returns the value of the authorize record component.
      Returns:
      the value of the authorize record component
    • login

      public OahLoginService login()
      Returns the value of the login record component.
      Returns:
      the value of the login record component