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 org.make.core.auth._ 23 import org.make.core.user.{User, UserId} 24 import scalaoauth2.provider._ 25 26 import scala.concurrent.Future 27 28 trait MakeDataHandlerComponent { 29 def oauth2DataHandler: MakeDataHandler 30 } 31 32 trait MakeDataHandler extends DataHandler[UserRights] { 33 def createAuthorizationCode( 34 userId: UserId, 35 clientId: ClientId, 36 scope: Option[String], 37 redirectUri: Option[String] 38 ): Future[Option[AuthCode]] 39 def removeTokenByUserId(userId: UserId): Future[Int] 40 def removeToken(token: String): Future[Unit] 41 def refreshIfTokenIsExpired(token: String): Future[Option[Token]] 42 } 43 44 object MakeDataHandler { 45 val RefreshTokenExpirationParameter: String = "refresh_expires_in" 46 val CreatedAtParameter: String = "created_at" 47 48 def insufficientRole(user: User, client: Client): String = { 49 s"User: ${user.userId} tried to connect to client ${client.clientId} with insufficient roles. " + 50 s"Expected one of: ${client.roles.map(_.value).mkString(", ")}." + 51 s"Actual: ${user.roles.map(_.value).mkString(", ")}" 52 } 53 }
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 45 | 29321 | 1457 - 1477 | Literal | <nosymbol> | "refresh_expires_in" | |
| 46 | 28521 | 1513 - 1525 | Literal | <nosymbol> | "created_at" | |
| 50 | 29784 | 1594 - 1823 | Apply | java.lang.String.+ | ("User: ".+(user.userId).+(" tried to connect to client ").+(client.clientId).+(" with insufficient roles. "): String).+(("Expected one of: ".+(client.roles.map[String](((x$1: org.make.core.user.Role) => x$1.value)).mkString(", ")).+("."): String)).+(("Actual: ".+(user.roles.map[String](((x$2: org.make.core.user.Role) => x$2.value)).mkString(", ")): String)) |