Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59d2abd

Browse files
committed
impl: improve auth manager config
- authentication and token endpoints are now passed via the login configuration object- similar for client_id and client_secret- PCKE is now enabled
1 parent79ba4cb commit59d2abd

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed
Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
packagecom.coder.toolbox.oauth
22

3-
importcom.coder.toolbox.util.toBaseURL
43
importcom.jetbrains.toolbox.api.core.auth.AuthConfiguration
54
importcom.jetbrains.toolbox.api.core.auth.ContentType
65
importcom.jetbrains.toolbox.api.core.auth.ContentType.FORM_URL_ENCODED
76
importcom.jetbrains.toolbox.api.core.auth.OAuthToken
87
importcom.jetbrains.toolbox.api.core.auth.PluginAuthInterface
98
importcom.jetbrains.toolbox.api.core.auth.RefreshConfiguration
109

11-
classCoderOAuthManager(
12-
privatevalclientId:String,
13-
privatevalauthServer:AuthorizationServer
14-
) : PluginAuthInterface<CoderAccount, CoderLoginCfg> {
10+
classCoderOAuthManager(privatevalcfg:CoderOAuthCfg) : PluginAuthInterface<CoderAccount, CoderOAuthCfg> {
1511
overridefunserialize(account:CoderAccount):String="${account.id}|${account.fullName}"
1612

1713
overridefundeserialize(string:String):CoderAccount=CoderAccount(
@@ -33,28 +29,49 @@ class CoderOAuthManager(
3329
TODO("Not yet implemented")
3430
}
3531

36-
overridefuncreateAuthConfig(loginConfiguration:CoderLoginCfg):AuthConfiguration=AuthConfiguration(
37-
authParams=mapOf("response_type" to"code","client_id" to clientId),
38-
tokenParams=mapOf("grant_type" to"authorization_code","client_id" to clientId),
39-
baseUrl= authServer.authorizationEndpoint.toBaseURL().toString(),
40-
authUrl= authServer.authorizationEndpoint,
41-
tokenUrl= authServer.tokenEndpoint,
42-
codeChallengeParamName="code_challenge",
43-
codeChallengeMethod="S256",
44-
verifierParamName="code_verifier",
45-
authorization=null
46-
)
32+
overridefuncreateAuthConfig(loginConfiguration:CoderOAuthCfg):AuthConfiguration {
33+
val codeVerifier=PKCEGenerator.generateCodeVerifier()
34+
val codeChallenge=PKCEGenerator.generateCodeChallenge(codeVerifier)
4735

36+
returnAuthConfiguration(
37+
authParams=mapOf(
38+
"client_id" to loginConfiguration.clientId,
39+
"response_type" to"code",
40+
"code_challenge" to codeChallenge
41+
),
42+
tokenParams=mapOf(
43+
"grant_type" to"authorization_code",
44+
"client_id" to loginConfiguration.clientId,
45+
"code_verifier" to codeVerifier
46+
),
47+
baseUrl= loginConfiguration.baseUrl,
48+
authUrl= loginConfiguration.authUrl,
49+
tokenUrl= loginConfiguration.tokenUrl,
50+
codeChallengeParamName="code_challenge",
51+
codeChallengeMethod="S256",
52+
verifierParamName="code_verifier",
53+
authorization=null
54+
)
55+
}
4856

4957
overridefuncreateRefreshConfig(account:CoderAccount):RefreshConfiguration {
5058
returnobject:RefreshConfiguration {
51-
overrideval refreshUrl:String= authServer.tokenEndpoint
52-
overrideval parameters:Map<String,String>=
53-
mapOf("grant_type" to"refresh_token","client_id" to clientId)
59+
overrideval refreshUrl:String= cfg.tokenUrl
60+
overrideval parameters:Map<String,String>=mapOf(
61+
"grant_type" to"refresh_token",
62+
"client_id" to cfg.clientId,
63+
"client_secret" to cfg.clientSecret
64+
)
5465
overrideval authorization:String?=null
5566
overrideval contentType:ContentType=FORM_URL_ENCODED
5667
}
5768
}
5869
}
5970

60-
object CoderLoginCfg
71+
data classCoderOAuthCfg(
72+
valbaseUrl:String,
73+
valauthUrl:String,
74+
valtokenUrl:String,
75+
valclientId:String,
76+
valclientSecret:String,
77+
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp