1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.technical.auth
21 
22 import java.time.ZonedDateTime
23 
24 import grizzled.slf4j.Logging
25 import org.make.api.extensions.MakeDBExecutionContextComponent
26 import org.make.api.technical.DatabaseTransactions._
27 import org.make.api.technical.ShortenedNames
28 import org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient
29 import org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken
30 import org.make.api.user.PersistentUserServiceComponent
31 import org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser
32 import org.make.core.DateHelper
33 import org.make.core.auth.Token
34 import org.make.core.user.UserId
35 import scalikejdbc._
36 
37 import scala.concurrent.Future
38 
39 object DefaultPersistentTokenServiceComponent {
40 
41   final case class PersistentToken(
42     accessToken: String,
43     refreshToken: Option[String],
44     scope: Option[String],
45     createdAt: Option[ZonedDateTime],
46     updatedAt: Option[ZonedDateTime],
47     expiresIn: Int,
48     refreshExpiresIn: Int,
49     makeUserUuid: PersistentUser,
50     clientUuid: PersistentClient
51   ) {
52     def toToken: Token = {
53       Token(
54         accessToken = accessToken,
55         refreshToken = refreshToken,
56         scope = scope,
57         createdAt = createdAt,
58         updatedAt = updatedAt,
59         expiresIn = expiresIn,
60         user = makeUserUuid.toUserRights,
61         client = clientUuid.toClient,
62         refreshExpiresIn = refreshExpiresIn
63       )
64     }
65   }
66 
67   object PersistentToken extends SQLSyntaxSupport[PersistentToken] with ShortenedNames with Logging {
68 
69     override val columnNames: Seq[String] =
70       Seq(
71         "access_token",
72         "refresh_token",
73         "scope",
74         "created_at",
75         "updated_at",
76         "expires_in",
77         "make_user_uuid",
78         "client_uuid",
79         "refresh_expires_in"
80       )
81 
82     override val tableName: String = "access_token"
83 
84     lazy val tokenAlias: QuerySQLSyntaxProvider[SQLSyntaxSupport[PersistentToken], PersistentToken] = syntax("t")
85 
86     def apply(
87       tokenResultName: ResultName[PersistentToken] = tokenAlias.resultName,
88       userResultName: ResultName[PersistentUser] = PersistentUser.alias.resultName,
89       clientResultName: ResultName[PersistentClient] = PersistentClient.alias.resultName
90     )(resultSet: WrappedResultSet): PersistentToken = {
91       val persistentUser = PersistentUser(userResultName)(resultSet)
92       val persistentClient = PersistentClient(clientResultName)(resultSet)
93       PersistentToken(
94         accessToken = resultSet.string(tokenResultName.accessToken),
95         refreshToken = resultSet.stringOpt(tokenResultName.refreshToken),
96         scope = resultSet.stringOpt(tokenResultName.scope),
97         createdAt = resultSet.zonedDateTimeOpt(tokenResultName.createdAt),
98         updatedAt = resultSet.zonedDateTimeOpt(tokenResultName.updatedAt),
99         expiresIn = resultSet.int(tokenResultName.expiresIn),
100         refreshExpiresIn = resultSet.int(tokenResultName.refreshExpiresIn),
101         makeUserUuid = persistentUser,
102         clientUuid = persistentClient
103       )
104     }
105   }
106 
107 }
108 
109 trait DefaultPersistentTokenServiceComponent extends PersistentTokenServiceComponent {
110   self: MakeDBExecutionContextComponent with PersistentUserServiceComponent with PersistentClientServiceComponent =>
111 
112   override lazy val persistentTokenService: PersistentTokenService = new DefaultPersistentTokenService
113 
114   class DefaultPersistentTokenService extends PersistentTokenService with ShortenedNames with Logging {
115 
116     private val tokenAlias = PersistentToken.tokenAlias
117     private val column = PersistentToken.column
118 
119     override def accessTokenExists(token: String): Future[Boolean] = {
120       get(token).map(_.isDefined)(ECGlobal)
121     }
122 
123     override def refreshTokenExists(token: String): Future[Boolean] = {
124       findByRefreshToken(token).map(_.isDefined)(ECGlobal)
125     }
126 
127     override def findByRefreshToken(token: String): Future[Option[Token]] = {
128       implicit val cxt: EC = readExecutionContext
129       val futurePersistentToken: Future[Option[PersistentToken]] = Future(NamedDB("READ").retryableTx {
130         implicit session =>
131           val userAlias = PersistentUser.alias
132           val clientAlias = PersistentClient.alias
133           withSQL {
134             val req: scalikejdbc.SQLBuilder[PersistentUser] = select
135               .from(PersistentToken.as(tokenAlias))
136               .innerJoin(PersistentUser.as(userAlias))
137               .on(userAlias.uuid, tokenAlias.makeUserUuid)
138               .innerJoin(PersistentClient.as(clientAlias))
139               .on(clientAlias.uuid, tokenAlias.clientUuid)
140               .where(sqls.eq(tokenAlias.refreshToken, token))
141             req
142           }.map(
143               PersistentToken(
144                 tokenResultName = tokenAlias.resultName,
145                 userResultName = userAlias.resultName,
146                 clientResultName = clientAlias.resultName
147               )
148             )
149             .single()
150       })
151 
152       futurePersistentToken.map(_.map(_.toToken))
153     }
154 
155     override def get(accessToken: String): Future[Option[Token]] = {
156       implicit val cxt: EC = readExecutionContext
157       val futurePersistentToken: Future[Option[PersistentToken]] = Future(NamedDB("READ").retryableTx {
158         implicit session =>
159           val userAlias = PersistentUser.alias
160           val clientAlias = PersistentClient.alias
161           withSQL {
162             select
163               .from(PersistentToken.as(tokenAlias))
164               .innerJoin(PersistentUser.as(userAlias))
165               .on(userAlias.uuid, tokenAlias.makeUserUuid)
166               .innerJoin(PersistentClient.as(clientAlias))
167               .on(clientAlias.uuid, tokenAlias.clientUuid)
168               .where(sqls.eq(tokenAlias.accessToken, accessToken))
169           }.map(PersistentToken.apply(tokenAlias.resultName, userAlias.resultName, clientAlias.resultName))
170             .single()
171       })
172 
173       futurePersistentToken.map(_.map(_.toToken))
174     }
175 
176     override def findByUserId(userId: UserId): Future[Option[Token]] = {
177       implicit val cxt: EC = readExecutionContext
178       val futurePersistentToken = Future(NamedDB("READ").retryableTx { implicit session =>
179         withSQL {
180           select
181             .from(PersistentToken.as(tokenAlias))
182             .innerJoin(PersistentUser.as(PersistentUser.alias))
183             .on(PersistentUser.alias.uuid, tokenAlias.makeUserUuid)
184             .innerJoin(PersistentClient.as(PersistentClient.alias))
185             .on(PersistentClient.alias.uuid, tokenAlias.clientUuid)
186             .where(sqls.eq(tokenAlias.makeUserUuid, userId.value))
187             .orderBy(tokenAlias.updatedAt)
188             .desc
189             .limit(1)
190         }.map(PersistentToken.apply()).single()
191       })
192 
193       futurePersistentToken.map(_.map(_.toToken))
194     }
195 
196     override def persist(token: Token): Future[Token] = {
197       implicit val ctx: EC = writeExecutionContext
198       Future(NamedDB("WRITE").retryableTx { implicit session =>
199         withSQL {
200           insert
201             .into(PersistentToken)
202             .namedValues(
203               column.accessToken -> token.accessToken,
204               column.refreshToken -> token.refreshToken,
205               column.scope -> token.scope,
206               column.createdAt -> DateHelper.now(),
207               column.updatedAt -> DateHelper.now(),
208               column.expiresIn -> token.expiresIn,
209               column.refreshExpiresIn -> token.refreshExpiresIn,
210               column.makeUserUuid -> token.user.userId.value,
211               column.clientUuid -> token.client.clientId.value
212             )
213         }.execute()
214       }).map(_ => token)
215     }
216 
217     override def deleteByAccessToken(accessToken: String): Future[Int] = {
218       implicit val ctx: EC = writeExecutionContext
219       Future(NamedDB("WRITE").retryableTx { implicit session =>
220         withSQL {
221           delete
222             .from(PersistentToken.as(tokenAlias))
223             .where
224             .eq(tokenAlias.accessToken, accessToken)
225         }.update()
226       })
227     }
228 
229     override def deleteByUserId(userId: UserId): Future[Int] = {
230       implicit val ctx: EC = writeExecutionContext
231       Future(NamedDB("WRITE").retryableTx { implicit session =>
232         withSQL {
233           delete
234             .from(PersistentToken.as(tokenAlias))
235             .where
236             .eq(tokenAlias.makeUserUuid, userId.value)
237         }.update()
238       })
239     }
240 
241   }
242 }
Line Stmt Id Pos Tree Symbol Tests Code
53 19607 1872 - 2198 Apply org.make.core.auth.Token.apply org.make.core.auth.Token.apply(x$1, x$2, x$3, x$6, x$9, x$7, x$8, x$4, x$5)
54 19541 1901 - 1912 Select org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.accessToken PersistentToken.this.accessToken
55 21172 1937 - 1949 Select org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.refreshToken PersistentToken.this.refreshToken
56 20601 1967 - 1972 Select org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.scope PersistentToken.this.scope
57 19670 1994 - 2003 Select org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.createdAt PersistentToken.this.createdAt
58 21249 2025 - 2034 Select org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.updatedAt PersistentToken.this.updatedAt
59 20361 2056 - 2065 Select org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.expiresIn PersistentToken.this.expiresIn
60 19926 2082 - 2107 Select org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.toUserRights PersistentToken.this.makeUserUuid.toUserRights
61 21404 2126 - 2145 Select org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.toClient PersistentToken.this.clientUuid.toClient
62 20452 2174 - 2190 Select org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.refreshExpiresIn PersistentToken.this.refreshExpiresIn
70 21177 2363 - 2585 Apply scala.collection.SeqFactory.Delegate.apply scala.`package`.Seq.apply[String]("access_token", "refresh_token", "scope", "created_at", "updated_at", "expires_in", "make_user_uuid", "client_uuid", "refresh_expires_in")
82 20720 2624 - 2638 Literal <nosymbol> "access_token"
91 19647 3102 - 3143 Apply org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.apply org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.apply(userResultName)(resultSet)
92 21357 3173 - 3218 Apply org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.apply org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.apply(clientResultName)(resultSet)
93 21170 3225 - 3817 Apply org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.apply DefaultPersistentTokenServiceComponent.this.PersistentToken.apply(resultSet.string(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("accessToken"): scalikejdbc.interpolation.SQLSyntax))), resultSet.stringOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("refreshToken"): scalikejdbc.interpolation.SQLSyntax))), resultSet.stringOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("scope"): scalikejdbc.interpolation.SQLSyntax))), resultSet.zonedDateTimeOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("createdAt"): scalikejdbc.interpolation.SQLSyntax))), resultSet.zonedDateTimeOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("updatedAt"): scalikejdbc.interpolation.SQLSyntax))), resultSet.int(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("expiresIn"): scalikejdbc.interpolation.SQLSyntax))), resultSet.int(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("refreshExpiresIn"): scalikejdbc.interpolation.SQLSyntax))), persistentUser, persistentClient)
94 20410 3281 - 3308 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("accessToken"): scalikejdbc.interpolation.SQLSyntax))
94 21874 3264 - 3309 Apply scalikejdbc.WrappedResultSet.string resultSet.string(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("accessToken"): scalikejdbc.interpolation.SQLSyntax)))
95 20511 3334 - 3383 Apply scalikejdbc.WrappedResultSet.stringOpt resultSet.stringOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("refreshToken"): scalikejdbc.interpolation.SQLSyntax)))
95 21410 3354 - 3382 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("refreshToken"): scalikejdbc.interpolation.SQLSyntax))
96 21166 3401 - 3443 Apply scalikejdbc.WrappedResultSet.stringOpt resultSet.stringOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("scope"): scalikejdbc.interpolation.SQLSyntax)))
96 19610 3421 - 3442 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("scope"): scalikejdbc.interpolation.SQLSyntax))
97 19652 3465 - 3518 Apply scalikejdbc.WrappedResultSet.zonedDateTimeOpt resultSet.zonedDateTimeOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("createdAt"): scalikejdbc.interpolation.SQLSyntax)))
97 20725 3492 - 3517 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("createdAt"): scalikejdbc.interpolation.SQLSyntax))
98 21324 3567 - 3592 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("updatedAt"): scalikejdbc.interpolation.SQLSyntax))
98 20412 3540 - 3593 Apply scalikejdbc.WrappedResultSet.zonedDateTimeOpt resultSet.zonedDateTimeOpt(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("updatedAt"): scalikejdbc.interpolation.SQLSyntax)))
99 21519 3615 - 3655 Apply scalikejdbc.WrappedResultSet.int resultSet.int(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("expiresIn"): scalikejdbc.interpolation.SQLSyntax)))
99 21967 3629 - 3654 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("expiresIn"): scalikejdbc.interpolation.SQLSyntax))
100 20514 3698 - 3730 ApplyImplicitView scalikejdbc.interpolation.Implicits.scalikejdbcSQLSyntaxToStringImplicitDef scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("refreshExpiresIn"): scalikejdbc.interpolation.SQLSyntax))
100 19586 3684 - 3731 Apply scalikejdbc.WrappedResultSet.int resultSet.int(scalikejdbc.`package`.scalikejdbcSQLSyntaxToStringImplicitDef((tokenResultName.field("refreshExpiresIn"): scalikejdbc.interpolation.SQLSyntax)))
117 20677 4327 - 4349 Select scalikejdbc.SQLSyntaxSupportFeature.SQLSyntaxSupport.column org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.column
120 20397 4428 - 4465 Apply scala.concurrent.Future.map DefaultPersistentTokenService.this.get(token).map[Boolean](((x$1: Option[org.make.core.auth.Token]) => x$1.isDefined))(DefaultPersistentTokenService.this.ECGlobal)
120 21330 4456 - 4464 Select org.make.api.technical.ShortenedNames.ECGlobal DefaultPersistentTokenService.this.ECGlobal
120 19684 4443 - 4454 Select scala.Option.isDefined x$1.isDefined
124 21453 4594 - 4602 Select org.make.api.technical.ShortenedNames.ECGlobal DefaultPersistentTokenService.this.ECGlobal
124 20477 4551 - 4603 Apply scala.concurrent.Future.map DefaultPersistentTokenService.this.findByRefreshToken(token).map[Boolean](((x$2: Option[org.make.core.auth.Token]) => x$2.isDefined))(DefaultPersistentTokenService.this.ECGlobal)
124 21954 4581 - 4592 Select scala.Option.isDefined x$2.isDefined
128 19589 4718 - 4738 Select org.make.api.extensions.MakeDBExecutionContextComponent.readExecutionContext DefaultPersistentTokenServiceComponent.this.readExecutionContext
129 21174 4806 - 5698 ApplyToImplicitArgs scala.concurrent.Future.apply scala.concurrent.Future.apply[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("READ") = "READ"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("READ", x$2); scalikejdbc.NamedDB.apply("READ", x$2)(x$3) }); <artifact> val x$7: scalikejdbc.DBSession => Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken] @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => { val userAlias: scalikejdbc.SyntaxProvider[org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser] = org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.alias; val clientAlias: scalikejdbc.SyntaxProvider[org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient] = org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.alias; { <synthetic> <stable> <artifact> val stabilizer$1: scalikejdbc.SQLToOption[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = scalikejdbc.`package`.withSQL.apply[org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser]({ val req: scalikejdbc.SQLBuilder[org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser] = scalikejdbc.`package`.select.from[org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser](org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.as(DefaultPersistentTokenService.this.tokenAlias)).innerJoin(org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.as(userAlias)).on((userAlias.field("uuid"): scalikejdbc.interpolation.SQLSyntax), (DefaultPersistentTokenService.this.tokenAlias.field("makeUserUuid"): scalikejdbc.interpolation.SQLSyntax)).innerJoin(org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.as(clientAlias)).on((clientAlias.field("uuid"): scalikejdbc.interpolation.SQLSyntax), (DefaultPersistentTokenService.this.tokenAlias.field("clientUuid"): scalikejdbc.interpolation.SQLSyntax)).where(scalikejdbc.`package`.sqls.eq[String]((DefaultPersistentTokenService.this.tokenAlias.field("refreshToken"): scalikejdbc.interpolation.SQLSyntax), token)(scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory)); req }).map[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken](((resultSet: scalikejdbc.WrappedResultSet) => org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.apply(DefaultPersistentTokenService.this.tokenAlias.resultName, userAlias.resultName, clientAlias.resultName)(resultSet))).single; { <artifact> val x$4: scalikejdbc.DBSession = session; <artifact> val x$5: scalikejdbc.SQL[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor] =:= scalikejdbc.SQL[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = GeneralizedTypeConstraintsForWithExtractor.this.=:=.tpEquals[scalikejdbc.SQL[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor]]; <artifact> val x$6: scalikejdbc.ConnectionPoolContext = stabilizer$1.apply$default$2(); stabilizer$1.apply()(x$4, x$6, x$5) } } }); <artifact> val x$8: scalikejdbc.TxBoundary[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]](x$7); qual$1.retryableTx[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]](x$7)(x$8) })(cxt)
152 20192 5706 - 5749 ApplyToImplicitArgs scala.concurrent.Future.map futurePersistentToken.map[Option[org.make.core.auth.Token]](((x$3: Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]) => x$3.map[org.make.core.auth.Token](((x$4: org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken) => x$4.toToken))))(cxt)
156 19645 5855 - 5875 Select org.make.api.extensions.MakeDBExecutionContextComponent.readExecutionContext DefaultPersistentTokenServiceComponent.this.readExecutionContext
157 21286 5943 - 6634 ApplyToImplicitArgs scala.concurrent.Future.apply scala.concurrent.Future.apply[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("READ") = "READ"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("READ", x$2); scalikejdbc.NamedDB.apply("READ", x$2)(x$3) }); <artifact> val x$7: scalikejdbc.DBSession => Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken] @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => { val userAlias: scalikejdbc.SyntaxProvider[org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser] = org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.alias; val clientAlias: scalikejdbc.SyntaxProvider[org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient] = org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.alias; { <synthetic> <stable> <artifact> val stabilizer$1: scalikejdbc.SQLToOption[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = scalikejdbc.`package`.withSQL.apply[Nothing](scalikejdbc.`package`.select.from[Nothing](org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.as(DefaultPersistentTokenService.this.tokenAlias)).innerJoin(org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.as(userAlias)).on((userAlias.field("uuid"): scalikejdbc.interpolation.SQLSyntax), (DefaultPersistentTokenService.this.tokenAlias.field("makeUserUuid"): scalikejdbc.interpolation.SQLSyntax)).innerJoin(org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.as(clientAlias)).on((clientAlias.field("uuid"): scalikejdbc.interpolation.SQLSyntax), (DefaultPersistentTokenService.this.tokenAlias.field("clientUuid"): scalikejdbc.interpolation.SQLSyntax)).where(scalikejdbc.`package`.sqls.eq[String]((DefaultPersistentTokenService.this.tokenAlias.field("accessToken"): scalikejdbc.interpolation.SQLSyntax), accessToken)(scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory))).map[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken](((resultSet: scalikejdbc.WrappedResultSet) => org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.apply(DefaultPersistentTokenService.this.tokenAlias.resultName, userAlias.resultName, clientAlias.resultName)(resultSet))).single; { <artifact> val x$4: scalikejdbc.DBSession = session; <artifact> val x$5: scalikejdbc.SQL[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor] =:= scalikejdbc.SQL[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = GeneralizedTypeConstraintsForWithExtractor.this.=:=.tpEquals[scalikejdbc.SQL[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor]]; <artifact> val x$6: scalikejdbc.ConnectionPoolContext = stabilizer$1.apply$default$2(); stabilizer$1.apply()(x$4, x$6, x$5) } } }); <artifact> val x$8: scalikejdbc.TxBoundary[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]](x$7); qual$1.retryableTx[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]](x$7)(x$8) })(cxt)
173 20316 6642 - 6685 ApplyToImplicitArgs scala.concurrent.Future.map futurePersistentToken.map[Option[org.make.core.auth.Token]](((x$5: Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]) => x$5.map[org.make.core.auth.Token](((x$6: org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken) => x$6.toToken))))(cxt)
177 21955 6795 - 6815 Select org.make.api.extensions.MakeDBExecutionContextComponent.readExecutionContext org.scalatest.testsuite DefaultPersistentTokenServiceComponent.this.readExecutionContext
178 21509 6850 - 7466 ApplyToImplicitArgs scala.concurrent.Future.apply org.scalatest.testsuite scala.concurrent.Future.apply[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("READ") = "READ"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("READ", x$2); scalikejdbc.NamedDB.apply("READ", x$2)(x$3) }); <artifact> val x$7: scalikejdbc.DBSession => Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken] @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => { <synthetic> <stable> <artifact> val stabilizer$1: scalikejdbc.SQLToOption[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = scalikejdbc.`package`.withSQL.apply[Nothing](scalikejdbc.`package`.select.from[Nothing](org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.as(DefaultPersistentTokenService.this.tokenAlias)).innerJoin(org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.as(org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.alias)).on((org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser.alias.field("uuid"): scalikejdbc.interpolation.SQLSyntax), (DefaultPersistentTokenService.this.tokenAlias.field("makeUserUuid"): scalikejdbc.interpolation.SQLSyntax)).innerJoin(org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.as(org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.alias)).on((org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient.alias.field("uuid"): scalikejdbc.interpolation.SQLSyntax), (DefaultPersistentTokenService.this.tokenAlias.field("clientUuid"): scalikejdbc.interpolation.SQLSyntax)).where(scalikejdbc.`package`.sqls.eq[String]((DefaultPersistentTokenService.this.tokenAlias.field("makeUserUuid"): scalikejdbc.interpolation.SQLSyntax), userId.value)(scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory)).orderBy((DefaultPersistentTokenService.this.tokenAlias.field("updatedAt"): scalikejdbc.interpolation.SQLSyntax)).desc.limit(1)).map[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]({ <synthetic> val eta$0$1: scalikejdbc.ResultName[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken] = org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.apply$default$1; <synthetic> val eta$1$1: scalikejdbc.ResultName[org.make.api.user.DefaultPersistentUserServiceComponent.PersistentUser] = org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.apply$default$2; <synthetic> val eta$2$1: scalikejdbc.ResultName[org.make.api.technical.auth.DefaultPersistentClientServiceComponent.PersistentClient] = org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.apply$default$3; ((resultSet: scalikejdbc.WrappedResultSet) => org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.apply(eta$0$1, eta$1$1, eta$2$1)(resultSet)) }).single; { <artifact> val x$4: scalikejdbc.DBSession = session; <artifact> val x$5: scalikejdbc.SQL[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor] =:= scalikejdbc.SQL[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor] @scala.reflect.internal.annotations.uncheckedBounds = GeneralizedTypeConstraintsForWithExtractor.this.=:=.tpEquals[scalikejdbc.SQL[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken,scalikejdbc.HasExtractor]]; <artifact> val x$6: scalikejdbc.ConnectionPoolContext = stabilizer$1.apply$default$2(); stabilizer$1.apply()(x$4, x$6, x$5) } }); <artifact> val x$8: scalikejdbc.TxBoundary[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]](x$7); qual$1.retryableTx[Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]](x$7)(x$8) })(cxt)
193 20437 7474 - 7517 ApplyToImplicitArgs scala.concurrent.Future.map org.scalatest.testsuite futurePersistentToken.map[Option[org.make.core.auth.Token]](((x$7: Option[org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken]) => x$7.map[org.make.core.auth.Token](((x$8: org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken) => x$8.toToken))))(cxt)
197 19548 7612 - 7633 Select org.make.api.extensions.MakeDBExecutionContextComponent.writeExecutionContext DefaultPersistentTokenServiceComponent.this.writeExecutionContext
214 21133 7640 - 8352 ApplyToImplicitArgs scala.concurrent.Future.map scala.concurrent.Future.apply[Boolean]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("WRITE") = "WRITE"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("WRITE", x$2); scalikejdbc.NamedDB.apply("WRITE", x$2)(x$3) }); <artifact> val x$4: scalikejdbc.DBSession => Boolean @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => scalikejdbc.`package`.withSQL.apply[scalikejdbc.UpdateOperation](scalikejdbc.`package`.insert.into(org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken).namedValues((DefaultPersistentTokenService.this.column.field("accessToken"): scalikejdbc.interpolation.SQLSyntax).->[String](token.accessToken)(scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory), (DefaultPersistentTokenService.this.column.field("refreshToken"): scalikejdbc.interpolation.SQLSyntax).->[Option[String]](token.refreshToken)(scalikejdbc.this.ParameterBinderFactory.optionalParameterBinderFactory[String](scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory)), (DefaultPersistentTokenService.this.column.field("scope"): scalikejdbc.interpolation.SQLSyntax).->[Option[String]](token.scope)(scalikejdbc.this.ParameterBinderFactory.optionalParameterBinderFactory[String](scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory)), (DefaultPersistentTokenService.this.column.field("createdAt"): scalikejdbc.interpolation.SQLSyntax).->[java.time.ZonedDateTime](org.make.core.DateHelper.now())(scalikejdbc.this.ParameterBinderFactory.javaTimeZonedDateTimeParameterBinderFactory), (DefaultPersistentTokenService.this.column.field("updatedAt"): scalikejdbc.interpolation.SQLSyntax).->[java.time.ZonedDateTime](org.make.core.DateHelper.now())(scalikejdbc.this.ParameterBinderFactory.javaTimeZonedDateTimeParameterBinderFactory), (DefaultPersistentTokenService.this.column.field("expiresIn"): scalikejdbc.interpolation.SQLSyntax).->[Int](token.expiresIn)(scalikejdbc.this.ParameterBinderFactory.intParameterBinderFactory), (DefaultPersistentTokenService.this.column.field("refreshExpiresIn"): scalikejdbc.interpolation.SQLSyntax).->[Int](token.refreshExpiresIn)(scalikejdbc.this.ParameterBinderFactory.intParameterBinderFactory), (DefaultPersistentTokenService.this.column.field("makeUserUuid"): scalikejdbc.interpolation.SQLSyntax).->[String](token.user.userId.value)(scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory), (DefaultPersistentTokenService.this.column.field("clientUuid"): scalikejdbc.interpolation.SQLSyntax).->[String](token.client.clientId.value)(scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory))).execute.apply()(session)); <artifact> val x$5: scalikejdbc.TxBoundary[Boolean] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Boolean](x$4); qual$1.retryableTx[Boolean](x$4)(x$5) })(ctx).map[org.make.core.auth.Token](((x$9: Boolean) => token))(ctx)
218 20193 8464 - 8485 Select org.make.api.extensions.MakeDBExecutionContextComponent.writeExecutionContext DefaultPersistentTokenServiceComponent.this.writeExecutionContext
219 19757 8492 - 8734 ApplyToImplicitArgs scala.concurrent.Future.apply scala.concurrent.Future.apply[Int]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("WRITE") = "WRITE"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("WRITE", x$2); scalikejdbc.NamedDB.apply("WRITE", x$2)(x$3) }); <artifact> val x$4: scalikejdbc.DBSession => Int @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => scalikejdbc.`package`.withSQL.apply[scalikejdbc.UpdateOperation](scalikejdbc.`package`.delete.from(org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.as(DefaultPersistentTokenService.this.tokenAlias)).where.eq[String]((DefaultPersistentTokenService.this.tokenAlias.field("accessToken"): scalikejdbc.interpolation.SQLSyntax), accessToken)(scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory)).update.apply()(session)); <artifact> val x$5: scalikejdbc.TxBoundary[Int] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Int](x$4); qual$1.retryableTx[Int](x$4)(x$5) })(ctx)
230 21228 8836 - 8857 Select org.make.api.extensions.MakeDBExecutionContextComponent.writeExecutionContext DefaultPersistentTokenServiceComponent.this.writeExecutionContext
231 20319 8864 - 9108 ApplyToImplicitArgs scala.concurrent.Future.apply scala.concurrent.Future.apply[Int]({ <artifact> val qual$1: org.make.api.technical.DatabaseTransactions.RichDatabase = org.make.api.technical.DatabaseTransactions.RichDatabase({ <artifact> val x$1: String("WRITE") = "WRITE"; <artifact> val x$2: scalikejdbc.SettingsProvider = scalikejdbc.NamedDB.apply$default$2; <artifact> val x$3: scalikejdbc.ConnectionPoolContext = scalikejdbc.NamedDB.apply$default$3("WRITE", x$2); scalikejdbc.NamedDB.apply("WRITE", x$2)(x$3) }); <artifact> val x$4: scalikejdbc.DBSession => Int @scala.reflect.internal.annotations.uncheckedBounds = ((implicit session: scalikejdbc.DBSession) => scalikejdbc.`package`.withSQL.apply[scalikejdbc.UpdateOperation](scalikejdbc.`package`.delete.from(org.make.api.technical.auth.DefaultPersistentTokenServiceComponent.PersistentToken.as(DefaultPersistentTokenService.this.tokenAlias)).where.eq[String]((DefaultPersistentTokenService.this.tokenAlias.field("makeUserUuid"): scalikejdbc.interpolation.SQLSyntax), userId.value)(scalikejdbc.this.ParameterBinderFactory.stringParameterBinderFactory)).update.apply()(session)); <artifact> val x$5: scalikejdbc.TxBoundary[Int] @scala.reflect.internal.annotations.uncheckedBounds = qual$1.retryableTx$default$2[Int](x$4); qual$1.retryableTx[Int](x$4)(x$5) })(ctx)