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 scala.concurrent.Future
23 
24 trait OauthTokenGenerator {
25   def generateAccessToken(): Future[(String, String)]
26   def generateRefreshToken(): Future[(String, String)]
27 }
28 
29 trait OauthTokenGeneratorComponent {
30   def oauthTokenGenerator: OauthTokenGenerator
31 }
32 
33 trait DefaultOauthTokenGeneratorComponent extends OauthTokenGeneratorComponent {
34   this: TokenGeneratorComponent with PersistentTokenServiceComponent =>
35 
36   override lazy val oauthTokenGenerator: OauthTokenGenerator = new DefaultOauthTokenGenerator
37 
38   class DefaultOauthTokenGenerator extends OauthTokenGenerator {
39     override def generateRefreshToken(): Future[(String, String)] = {
40       tokenGenerator.generateToken(persistentTokenService.refreshTokenExists)
41     }
42 
43     override def generateAccessToken(): Future[(String, String)] = {
44       tokenGenerator.generateToken(persistentTokenService.accessTokenExists)
45     }
46   }
47 }
Line Stmt Id Pos Tree Symbol Tests Code
40 29998 1446 - 1446 Select org.make.api.technical.auth.TokenGenerator.generateToken$default$2 qual$1.generateToken$default$2
40 28649 1460 - 1501 Apply org.make.api.technical.auth.PersistentTokenService.refreshTokenExists eta$0$1.refreshTokenExists(token)
40 29432 1431 - 1445 Select org.make.api.technical.auth.TokenGeneratorComponent.tokenGenerator DefaultOauthTokenGeneratorComponent.this.tokenGenerator
40 29213 1431 - 1502 Apply org.make.api.technical.auth.TokenGenerator.generateToken qual$1.generateToken(x$1, x$2)
44 29283 1600 - 1600 Select org.make.api.technical.auth.TokenGenerator.generateToken$default$2 qual$1.generateToken$default$2
44 28478 1585 - 1655 Apply org.make.api.technical.auth.TokenGenerator.generateToken qual$1.generateToken(x$1, x$2)
44 28735 1585 - 1599 Select org.make.api.technical.auth.TokenGeneratorComponent.tokenGenerator DefaultOauthTokenGeneratorComponent.this.tokenGenerator
44 30140 1614 - 1654 Apply org.make.api.technical.auth.PersistentTokenService.accessTokenExists eta$0$1.accessTokenExists(token)