-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OAuth implementation. #91
Conversation
@takke だいぶ参考にさせてもらったので、レビューお願いしたいです! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ざっとコードを読んだだけですが(手元での動作確認はできていませんが)、
- 従来の
accessJwt
をAuthProvider
にラップして、BearerTokenAuthProvider
とOAuthProvider
に分離する getWithAuth
,postWithAuth
でリクエストの前後をフックして、認証ヘッダーの設定と(DPoPNonceの)収集を行う
という流れは自分が OAuth 対応するならやろうと思っていたことのイメージと合っているので、この流れでいい感じだと思います!
fun postProcess( | ||
method: String, | ||
request: HttpRequest, | ||
response: HttpResponse, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
postProcess
という名前がちょっぴり HTTP POST Reqeust と勘違いしそうです(最初、勘違いしました・・・)。
できれば変更してもらえると読みやすくなるかなーと思いました。
他の候補を copilot に聞いてみました。
- afterRequestProcessing
- postRequestHook
- postRequestHandler
- finalizeRequest
- afterRequestCompletion
@@ -59,7 +63,7 @@ object _InternalUtility { | |||
inline fun <reified T> proceed(function: () -> HttpResponse): Response<T> { | |||
try { | |||
val response: HttpResponse = function() | |||
if (response.status == 200) { | |||
if ((response.status >= 200) && (response.status < 300)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (response.status in 200..299) {
のように書くと直感的かもしれません
var redirectUri: String? = null | ||
|
||
var state: String? = null | ||
var codeVerifier: String? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ライブラリの利用者は AuthProvider
として OAuthProvider
を OAuthContext
を用意して作ることになると思います。
redirectUri
, state
, codeVerifier
は厳密には OAuth の認証・認可の処理だけで必要なので、理想的には別のクラスに(つまり認証・認可用とそれ以降のAPIアクセス用に分離)したほうがいいのかなーと思いました。
が、影響がけっこう大きいので今後作成されるREADMEにどのメンバーを用意すればいいかが書かれていればひとまず十分かなーと思いました。
@coderabbitai please review |
@uakihir0, I will review the changes. ✅ Actions performedReview triggered.
|
全体的にまだ色々ブラッシュアップをする予定
終わったら 0.3 のバージョンを切る予定。