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 Summary
ConstructorsConstructorDescriptionOahOAuth(OahStateService state, OahAuthorizeUrlBuilder authorize, OahLoginService login) Creates an instance of aOahOAuthrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theauthorizerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.login()Returns the value of theloginrecord component.state()Returns the value of thestaterecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
OahOAuth
Creates an instance of aOahOAuthrecord class.- Parameters:
state- the value for thestaterecord componentauthorize- the value for theauthorizerecord componentlogin- the value for theloginrecord component
-
-
Method Details
-
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). -
state
Returns the value of thestaterecord component.- Returns:
- the value of the
staterecord component
-
authorize
Returns the value of theauthorizerecord component.- Returns:
- the value of the
authorizerecord component
-
login
Returns the value of theloginrecord component.- Returns:
- the value of the
loginrecord component
-