Record Class ClientCredentialsRequest
java.lang.Object
java.lang.Record
io.leandev.appfuse.security.auth.ClientCredentialsRequest
- Record Components:
grantType-grant_typeclientId-client_idclientSecret-client_secretscope-scope(本端點尚未支援;非空即拒,見OAuth2TokenException.invalidScope())
public record ClientCredentialsRequest(String grantType, String clientId, String clientSecret, String scope)
extends Record
client_credentials 的請求參數(RFC 6749 §4.4.2)
線格式的解析歸 capability(ADR-025
決策二)——RFC 6749 是標準、不是 per-project 決策,讓每個消費端各自實作解析與 client
認證方式,就是線格式漂移的來源。消費端的殼只負責把 HTTP 請求的參數 map 與
Authorization 標頭交進來,並選擇錯誤序列化的方言。
這與登入刻意不對稱:「登入」沒有標準,故其路徑與 DTO 形狀歸殼(ADR-023)。
-
Constructor Summary
ConstructorsConstructorDescriptionClientCredentialsRequest(String grantType, String clientId, String clientSecret, String scope) Creates an instance of aClientCredentialsRequestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionclientId()Returns the value of theclientIdrecord component.Returns the value of theclientSecretrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thegrantTyperecord component.final inthashCode()Returns a hash code value for this object.static ClientCredentialsRequest由請求參數與Authorization標頭組出請求scope()Returns the value of thescoperecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ClientCredentialsRequest
public ClientCredentialsRequest(String grantType, String clientId, String clientSecret, String scope) Creates an instance of aClientCredentialsRequestrecord class.- Parameters:
grantType- the value for thegrantTyperecord componentclientId- the value for theclientIdrecord componentclientSecret- the value for theclientSecretrecord componentscope- the value for thescoperecord component
-
-
Method Details
-
of
由請求參數與
Authorization標頭組出請求支援 RFC 6749 §2.3.1 的兩種 client 認證方式:
client_secret_basic:Authorization: Basic base64(urlencode(id) ":" urlencode(secret))——規範要求 AS MUST 支援,多數 client library 的預設client_secret_post:client_id/client_secret置於請求參數
兩者不得並用(§2.3「client MUST NOT use more than one authentication method」)→
invalid_request。- Parameters:
params- 請求參數(form-urlencoded 或等價的 JSON 欄位);null 視為空authorizationHeader-Authorization標頭原值;null/非 Basic 則忽略- Throws:
OAuth2TokenException- Basic 標頭格式錯誤,或兩種認證方式並用
-
toString
-
hashCode
-
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). -
grantType
-
clientId
-
clientSecret
Returns the value of theclientSecretrecord component.- Returns:
- the value of the
clientSecretrecord component
-
scope
-