Skip to content

Commit 6c1a380

Browse files
authored
use latest scalafmt (#158)
1 parent 366b6bc commit 6c1a380

File tree

8 files changed

+133
-104
lines changed

8 files changed

+133
-104
lines changed

.scalafmt.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
version = 2.7.5
1+
version = 3.7.14
22
project.git = true
3+
runner.dialect = scala3

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
1+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")

src/main/scala/scalaoauth2/provider/AuthorizationHandler.scala

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,58 @@ import scala.concurrent.Future
66
*
77
* <h3>[Authorization phases]</h3>
88
*
9-
* <h4>Authorization Code Grant</h4>
10-
* <ul>
11-
* <li>validateClient(request)</li>
12-
* <li>findAuthInfoByCode(code)</li>
13-
* <li>deleteAuthCode(code)</li>
14-
* <li>getStoredAccessToken(authInfo)</li>
15-
* <li>refreshAccessToken(authInfo, token)</li>
16-
* <li>createAccessToken(authInfo)</li>
17-
* </ul>
9+
* <h4>Authorization Code Grant</h4> <ul> <li>validateClient(request)</li>
10+
* <li>findAuthInfoByCode(code)</li> <li>deleteAuthCode(code)</li>
11+
* <li>getStoredAccessToken(authInfo)</li> <li>refreshAccessToken(authInfo,
12+
* token)</li> <li>createAccessToken(authInfo)</li> </ul>
1813
*
19-
* <h4>Refresh Token Grant</h4>
20-
* <ul>
21-
* <li>validateClient(clientCredential, grantType)</li>
22-
* <li>findAuthInfoByRefreshToken(refreshToken)</li>
23-
* <li>refreshAccessToken(authInfo, refreshToken)</li>
24-
* </ul>
14+
* <h4>Refresh Token Grant</h4> <ul> <li>validateClient(clientCredential,
15+
* grantType)</li> <li>findAuthInfoByRefreshToken(refreshToken)</li>
16+
* <li>refreshAccessToken(authInfo, refreshToken)</li> </ul>
2517
*
26-
* <h4>Resource Owner Password Credentials Grant</h4>
27-
* <ul>
28-
* <li>validateClient(request)</li>
29-
* <li>findUser(request)</li>
30-
* <li>getStoredAccessToken(authInfo)</li>
31-
* <li>refreshAccessToken(authInfo, token)</li>
32-
* <li>createAccessToken(authInfo)</li>
33-
* </ul>
18+
* <h4>Resource Owner Password Credentials Grant</h4> <ul>
19+
* <li>validateClient(request)</li> <li>findUser(request)</li>
20+
* <li>getStoredAccessToken(authInfo)</li> <li>refreshAccessToken(authInfo,
21+
* token)</li> <li>createAccessToken(authInfo)</li> </ul>
3422
*
35-
* <h4>Client Credentials Grant</h4>
36-
* <ul>
37-
* <li>validateClient(request)</li>
38-
* <li>findUser(request)</li>
39-
* <li>getStoredAccessToken(authInfo)</li>
40-
* <li>refreshAccessToken(authInfo, token)</li>
41-
* <li>createAccessToken(authInfo)</li>
42-
* </ul>
23+
* <h4>Client Credentials Grant</h4> <ul> <li>validateClient(request)</li>
24+
* <li>findUser(request)</li> <li>getStoredAccessToken(authInfo)</li>
25+
* <li>refreshAccessToken(authInfo, token)</li>
26+
* <li>createAccessToken(authInfo)</li> </ul>
4327
*
44-
* <h4>Implicit Grant</h4>
45-
* <ul>
46-
* <li>validateClient(request)</li>
47-
* <li>findUser(request)</li>
48-
* <li>getStoredAccessToken(authInfo)</li>
49-
* <li>createAccessToken(authInfo)</li>
50-
* </ul>
28+
* <h4>Implicit Grant</h4> <ul> <li>validateClient(request)</li>
29+
* <li>findUser(request)</li> <li>getStoredAccessToken(authInfo)</li>
30+
* <li>createAccessToken(authInfo)</li> </ul>
5131
*/
5232
trait AuthorizationHandler[U] {
5333

54-
/** Verify proper client with parameters for issue an access token.
55-
* Note that per the OAuth Specification, a Client may be valid if it only contains a client ID but no client
56-
* secret (common with Public Clients). However, if the registered client has a client secret value the specification
57-
* requires that a client secret must always be provided and verified for that client ID.
34+
/** Verify proper client with parameters for issue an access token. Note that
35+
* per the OAuth Specification, a Client may be valid if it only contains a
36+
* client ID but no client secret (common with Public Clients). However, if
37+
* the registered client has a client secret value the specification requires
38+
* that a client secret must always be provided and verified for that client
39+
* ID.
5840
*
59-
* @param maybeCredential client credential parsed from request
60-
* @param request Request sent by client.
61-
* @return true if request is a regular client, false if request is a illegal client.
41+
* @param maybeCredential
42+
* client credential parsed from request
43+
* @param request
44+
* Request sent by client.
45+
* @return
46+
* true if request is a regular client, false if request is a illegal
47+
* client.
6248
*/
6349
def validateClient(
6450
maybeCredential: Option[ClientCredential],
6551
request: AuthorizationRequest
6652
): Future[Boolean]
6753

68-
/** Authenticate the user that issued the authorization request.
69-
* Client credential, Password and Implicit Grant call this method.
54+
/** Authenticate the user that issued the authorization request. Client
55+
* credential, Password and Implicit Grant call this method.
7056
*
71-
* @param maybeCredential client credential parsed from request
72-
* @param request Request sent by client.
57+
* @param maybeCredential
58+
* client credential parsed from request
59+
* @param request
60+
* Request sent by client.
7361
*/
7462
def findUser(
7563
maybeCredential: Option[ClientCredential],
@@ -78,24 +66,30 @@ trait AuthorizationHandler[U] {
7866

7967
/** Creates a new access token by authorized information.
8068
*
81-
* @param authInfo This value is already authorized by system.
82-
* @return Access token returns to client.
69+
* @param authInfo
70+
* This value is already authorized by system.
71+
* @return
72+
* Access token returns to client.
8373
*/
8474
def createAccessToken(authInfo: AuthInfo[U]): Future[AccessToken]
8575

8676
/** Returns stored access token by authorized information.
8777
*
8878
* If want to create new access token then have to return None
8979
*
90-
* @param authInfo This value is already authorized by system.
91-
* @return Access token returns to client.
80+
* @param authInfo
81+
* This value is already authorized by system.
82+
* @return
83+
* Access token returns to client.
9284
*/
9385
def getStoredAccessToken(authInfo: AuthInfo[U]): Future[Option[AccessToken]]
9486

9587
/** Creates a new access token by refreshToken.
9688
*
97-
* @param authInfo This value is already authorized by system.
98-
* @return Access token returns to client.
89+
* @param authInfo
90+
* This value is already authorized by system.
91+
* @return
92+
* Access token returns to client.
9993
*/
10094
def refreshAccessToken(
10195
authInfo: AuthInfo[U],
@@ -104,30 +98,37 @@ trait AuthorizationHandler[U] {
10498

10599
/** Find authorized information by authorization code.
106100
*
107-
* If you don't support Authorization Code Grant then doesn't need implementing.
101+
* If you don't support Authorization Code Grant then doesn't need
102+
* implementing.
108103
*
109-
* @param code Client sends authorization code which is registered by system.
110-
* @return Return authorized information that matched the code.
104+
* @param code
105+
* Client sends authorization code which is registered by system.
106+
* @return
107+
* Return authorized information that matched the code.
111108
*/
112109
def findAuthInfoByCode(code: String): Future[Option[AuthInfo[U]]]
113110

114111
/** Deletes an authorization code.
115112
*
116-
* Called when an AccessToken has been successfully issued via an authorization code.
113+
* Called when an AccessToken has been successfully issued via an
114+
* authorization code.
117115
*
118-
* If you don't support Authorization Code Grant, then you don't need to implement this
119-
* method.
116+
* If you don't support Authorization Code Grant, then you don't need to
117+
* implement this method.
120118
*
121-
* @param code Client-sent authorization code
119+
* @param code
120+
* Client-sent authorization code
122121
*/
123122
def deleteAuthCode(code: String): Future[Unit]
124123

125124
/** Find authorized information by refresh token.
126125
*
127126
* If you don't support Refresh Token Grant then doesn't need implementing.
128127
*
129-
* @param refreshToken Client sends refresh token which is created by system.
130-
* @return Return authorized information that matched the refresh token.
128+
* @param refreshToken
129+
* Client sends refresh token which is created by system.
130+
* @return
131+
* Return authorized information that matched the refresh token.
131132
*/
132133
def findAuthInfoByRefreshToken(
133134
refreshToken: String

src/main/scala/scalaoauth2/provider/AuthorizationRequest.scala

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ case class RefreshTokenRequest(request: AuthorizationRequest)
6767

6868
/** returns refresh_token.
6969
*
70-
* @return code.
71-
* @throws InvalidRequest if the parameter is not found
70+
* @return
71+
* code.
72+
* @throws InvalidRequest
73+
* if the parameter is not found
7274
*/
7375
def refreshToken: String = requireParam("refresh_token")
7476
}
@@ -78,15 +80,19 @@ case class PasswordRequest(request: AuthorizationRequest)
7880

7981
/** returns username.
8082
*
81-
* @return username.
82-
* @throws InvalidRequest if the parameter is not found
83+
* @return
84+
* username.
85+
* @throws InvalidRequest
86+
* if the parameter is not found
8387
*/
8488
def username = requireParam("username")
8589

8690
/** returns password.
8791
*
88-
* @return password.
89-
* @throws InvalidRequest if the parameter is not found
92+
* @return
93+
* password.
94+
* @throws InvalidRequest
95+
* if the parameter is not found
9096
*/
9197
def password = requireParam("password")
9298
}
@@ -99,14 +105,17 @@ case class AuthorizationCodeRequest(request: AuthorizationRequest)
99105

100106
/** returns code.
101107
*
102-
* @return code.
103-
* @throws InvalidRequest if code is not found
108+
* @return
109+
* code.
110+
* @throws InvalidRequest
111+
* if code is not found
104112
*/
105113
def code: String = requireParam("code")
106114

107115
/** Returns redirect_uri.
108116
*
109-
* @return redirect_uri
117+
* @return
118+
* redirect_uri
110119
*/
111120
def redirectUri: Option[String] = param("redirect_uri")
112121

src/main/scala/scalaoauth2/provider/DataHandler.scala

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ trait DataHandler[U]
1212

1313
/** Access token
1414
*
15-
* @param token Access token is used to authentication.
16-
* @param refreshToken Refresh token is used to re-issue access token.
17-
* @param scope Inform the client of the scope of the access token issued.
18-
* @param lifeSeconds Life of the access token since its creation. In seconds.
19-
* @param createdAt Access token is created date.
20-
* @param params Additional parameters to add information/restriction on given Access token.
15+
* @param token
16+
* Access token is used to authentication.
17+
* @param refreshToken
18+
* Refresh token is used to re-issue access token.
19+
* @param scope
20+
* Inform the client of the scope of the access token issued.
21+
* @param lifeSeconds
22+
* Life of the access token since its creation. In seconds.
23+
* @param createdAt
24+
* Access token is created date.
25+
* @param params
26+
* Additional parameters to add information/restriction on given Access
27+
* token.
2128
*/
2229
case class AccessToken(
2330
token: String,
@@ -52,19 +59,25 @@ object CodeChallengeMethod {
5259
value match {
5360
case "S256" => Success(S256)
5461
case "plain" => Success(Plain)
55-
case _ => Failure(new InvalidRequest("transform algorithm not supported"))
62+
case _ => Failure(new InvalidRequest("transform algorithm not supported"))
5663
}
5764
}
5865
}
5966

6067
/** Authorized information
6168
*
62-
* @param user Authorized user which is registered on system.
63-
* @param clientId Using client id which is registered on system.
64-
* @param scope Inform the client of the scope of the access token issued.
65-
* @param redirectUri This value is used by Authorization Code Grant.
66-
* @param codeChallenge This value is used by Authorization Code Grant for PKCE support.
67-
* @param codeChallengeMethod This value is used by Authorization Code Grant for PKCE support.
69+
* @param user
70+
* Authorized user which is registered on system.
71+
* @param clientId
72+
* Using client id which is registered on system.
73+
* @param scope
74+
* Inform the client of the scope of the access token issued.
75+
* @param redirectUri
76+
* This value is used by Authorization Code Grant.
77+
* @param codeChallenge
78+
* This value is used by Authorization Code Grant for PKCE support.
79+
* @param codeChallengeMethod
80+
* This value is used by Authorization Code Grant for PKCE support.
6881
*/
6982
case class AuthInfo[+U](
7083
user: U,

src/main/scala/scalaoauth2/provider/GrantHandler.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ case class GrantHandlerResult[U](
1717

1818
trait GrantHandler {
1919

20-
/** Controls whether client credentials are required. Defaults to true but can be overridden to be false when needed.
21-
* Per the OAuth2 specification, client credentials are required for all grant types except password, where it is up
22-
* to the authorization provider whether to make them required or not.
20+
/** Controls whether client credentials are required. Defaults to true but can
21+
* be overridden to be false when needed. Per the OAuth2 specification,
22+
* client credentials are required for all grant types except password, where
23+
* it is up to the authorization provider whether to make them required or
24+
* not.
2325
*/
2426
def clientCredentialRequired = true
2527

@@ -105,8 +107,8 @@ class Password extends GrantHandler {
105107
handler: AuthorizationHandler[U]
106108
)(implicit ctx: ExecutionContext): Future[GrantHandlerResult[U]] = {
107109

108-
/** Given that client credentials may be optional, if they are required, they must be fully validated before
109-
* further processing.
110+
/** Given that client credentials may be optional, if they are required,
111+
* they must be fully validated before further processing.
110112
*/
111113
if (clientCredentialRequired && maybeValidatedClientCred.isEmpty) {
112114
throw new InvalidRequest("Client credential is required")

src/main/scala/scalaoauth2/provider/ProtectedResourceHandler.scala

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,32 @@ package scalaoauth2.provider
22

33
import scala.concurrent.Future
44

5-
/** Provide access to <b>Protected Resource</b> phase support for using OAuth 2.0.
5+
/** Provide access to <b>Protected Resource</b> phase support for using OAuth
6+
* 2.0.
67
*
7-
* <h3>[Access to Protected Resource phase]</h3>
8-
* <ul>
9-
* <li>findAccessToken(token)</li>
10-
* <li>findAuthInfoByAccessToken(token)</li>
8+
* <h3>[Access to Protected Resource phase]</h3> <ul>
9+
* <li>findAccessToken(token)</li> <li>findAuthInfoByAccessToken(token)</li>
1110
* </ul>
1211
*/
1312
trait ProtectedResourceHandler[+U] {
1413

1514
/** Find authorized information by access token.
1615
*
17-
* @param accessToken This value is AccessToken.
18-
* @return Return authorized information if the parameter is available.
16+
* @param accessToken
17+
* This value is AccessToken.
18+
* @return
19+
* Return authorized information if the parameter is available.
1920
*/
2021
def findAuthInfoByAccessToken(
2122
accessToken: AccessToken
2223
): Future[Option[AuthInfo[U]]]
2324

2425
/** Find AccessToken object by access token code.
2526
*
26-
* @param token Client sends access token which is created by system.
27-
* @return Return access token that matched the token.
27+
* @param token
28+
* Client sends access token which is created by system.
29+
* @return
30+
* Return access token that matched the token.
2831
*/
2932
def findAccessToken(token: String): Future[Option[AccessToken]]
3033

0 commit comments

Comments
 (0)