Skip to content
This repository has been archived by the owner on Sep 12, 2021. It is now read-only.

Commit

Permalink
Merge 9085e33 into 1ff7b5f
Browse files Browse the repository at this point in the history
  • Loading branch information
ahjohannessen authored Jun 27, 2019
2 parents 1ff7b5f + 9085e33 commit 174b74f
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ dist
/.settings
/.target
/.cache
*.DS_Store
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: scala
scala:
- 2.11.12
- 2.12.8
- 2.13.0
jdk:
- oraclejdk8
- openjdk11
Expand Down
34 changes: 24 additions & 10 deletions project/BuildSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,26 @@ object BasicSettings extends AutoPlugin {

override def projectSettings = Seq(
organization := "com.mohiva",
version := "6.0.0",
version := "6.0.1",
resolvers ++= Dependencies.resolvers,
scalaVersion := Dependencies.Versions.scalaVersion,
crossScalaVersions := Dependencies.Versions.crossScala,
scalacOptions ++= Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Xlint", // Enable recommended additional warnings.
"-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver.
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
"-Ywarn-nullary-override", // Warn when non-nullary overrides nullary, e.g. def foo() over def foo.
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Xlint", // Enable recommended additional warnings.,
"-Xlint:inaccessible", // Warn about inaccessible types in method signatures.
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-numeric-widen" // Warn when numerics are widened.
),
scalacOptions ++= {
if(Util.priorTo213(scalaVersion.value)) Seq(
"-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver.
"-Ywarn-nullary-override" // Warn when non-nullary overrides nullary, e.g. def foo() over def foo.
) else Nil
},
scalacOptions in Test ~= { options: Seq[String] =>
options filterNot (_ == "-Ywarn-dead-code") // Allow dead code in tests (to support using mockito).
},
Expand Down Expand Up @@ -207,3 +211,13 @@ object Publish extends AutoPlugin {
pomExtra := pom
)
}

object Util {

def priorTo213(scalaVersion: String): Boolean =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, minor)) if minor < 13 => true
case _ => false
}

}
10 changes: 5 additions & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import sbt._
object Dependencies {

object Versions {
val crossScala = Seq("2.12.8", "2.11.12")
val crossScala = Seq("2.13.0", "2.12.8", "2.11.12")
val scalaVersion = crossScala.head
}

Expand All @@ -35,11 +35,11 @@ object Dependencies {
val test = "com.typesafe.play" %% "play-test" % version
val specs2 = "com.typesafe.play" %% "play-specs2" % version
val openid = "com.typesafe.play" %% "play-openid" % version
val jsonJoda = "com.typesafe.play" %% "play-json-joda" % version
val jsonJoda = "com.typesafe.play" %% "play-json-joda" % "2.7.4"
}

object Specs2 {
private val version = "4.3.6"
private val version = "4.5.1"
val core = "org.specs2" %% "specs2-core" % version
val matcherExtra = "org.specs2" %% "specs2-matcher-extra" % version
val mock = "org.specs2" %% "specs2-mock" % version
Expand All @@ -48,8 +48,8 @@ object Dependencies {
val jbcrypt = "de.svenkubiak" % "jBCrypt" % "0.4.1"
val jwtCore = "com.atlassian.jwt" % "jwt-core" % "2.0.5"
val jwtApi = "com.atlassian.jwt" % "jwt-api" % "2.0.5"
val scalaGuice = "net.codingwell" %% "scala-guice" % "4.2.2"
val akkaTestkit = "com.typesafe.akka" %% "akka-testkit" % "2.5.19"
val scalaGuice = "net.codingwell" %% "scala-guice" % "4.2.5"
val akkaTestkit = "com.typesafe.akka" %% "akka-testkit" % "2.5.23"
val casClient = "org.jasig.cas.client" % "cas-client-core" % "3.4.1"
val casClientSupportSAML = "org.jasig.cas.client" % "cas-client-support-saml" % "3.4.1"
val apacheCommonLang = "org.apache.commons" % "commons-lang3" % "3.8.1"
Expand Down
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Comment to get more information during initialization
logLevel := Level.Warn

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.2")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.3")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.1.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")

addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")

Expand Down
2 changes: 1 addition & 1 deletion scripts/sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
#
set -o nounset -o errexit

scripts/sbt-runner -jvm-opts project/build-jvm-opts "$@"
scripts/sbt-runner -jvm-opts project/build-jvm-opts ++$TRAVIS_SCALA_VERSION "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.jasig.cas.client.authentication.AttributePrincipal
import org.jasig.cas.client.validation.{ AbstractUrlBasedTicketValidator, _ }
import play.api.mvc.{ Result, Results }

import scala.collection.JavaConverters._
import com.mohiva.play.silhouette.ScalaCompat.JavaConverters._
import scala.concurrent.duration._
import scala.concurrent.{ ExecutionContext, Future }
import scala.util.Try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.mohiva.play.silhouette.impl.providers

import com.mohiva.play.silhouette.api.exceptions.ConfigurationException
import com.mohiva.play.silhouette.api.exceptions.{ ConfigurationException, SilhouetteException }
import com.mohiva.play.silhouette.api.util.HTTPLayer
import com.mohiva.play.silhouette.api.{ Logger, LoginInfo }
import org.jasig.cas.client.authentication.AttributePrincipal
Expand Down Expand Up @@ -103,7 +103,8 @@ class CasProviderSpec extends SocialProviderSpec[CasInfo] with Mockito with Logg

val futureProfile = for {
a <- provider.authenticate()
p <- provider.retrieveProfile(a.right.get)
c <- a.fold(_ => Future.failed(new SilhouetteException("Missing CasInfo")), Future.successful)
p <- provider.retrieveProfile(c)
} yield p

await(futureProfile) must beLike[CommonSocialProfile] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class DelegableAuthInfoRepositorySpec(implicit ev: ExecutionEnv)
/**
* Configures the module.
*/
override def configure() {
override def configure(): Unit = {
bind[DelegableAuthInfoDAO[PasswordInfo]].toInstance(passwordInfoDAO)
bind[DelegableAuthInfoDAO[OAuth1Info]].toInstance(oauth1InfoDAO)
bind[DelegableAuthInfoDAO[OAuth2Info]].toInstance(oauth2InfoDAO)
Expand Down
12 changes: 12 additions & 0 deletions silhouette/app-2.13+/com/mohiva/play/silhouette/ScalaCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mohiva.play.silhouette

import scala.collection.immutable.Map

private[silhouette] object ScalaCompat {

implicit class MapOps[K, V](val map: Map[K, V]) extends AnyVal {
def transformValues[W](f: V => W): Map[K, W] = map.view.mapValues(f).toMap
}

val JavaConverters = scala.jdk.CollectionConverters
}
12 changes: 12 additions & 0 deletions silhouette/app-2.13-/com/mohiva/play/silhouette/ScalaCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mohiva.play.silhouette

import scala.collection.immutable.Map

private[silhouette] object ScalaCompat {

implicit class MapOps[K, V](val map: Map[K, V]) extends AnyVal {
def transformValues[W](f: V => W): Map[K, W] = map.mapValues(f)
}

val JavaConverters = scala.collection.JavaConverters
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import org.joda.time.DateTime
import play.api.libs.json._
import play.api.mvc.{ RequestHeader, Result }

import scala.collection.JavaConverters._
import com.mohiva.play.silhouette.ScalaCompat.JavaConverters._
import scala.concurrent.duration._
import scala.concurrent.{ ExecutionContext, Future }
import scala.util.{ Failure, Success, Try }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.mohiva.play.silhouette.api.util.ExtractableRequest
import com.mohiva.play.silhouette.impl.exceptions.{ AccessDeniedException, UnexpectedResponseException }
import com.mohiva.play.silhouette.impl.providers.OAuth2Provider._
import com.mohiva.play.silhouette.impl.providers.state.UserStateItemHandler
import com.mohiva.play.silhouette.ScalaCompat._
import play.api.libs.functional.syntax._
import play.api.libs.json._
import play.api.libs.ws.WSResponse
Expand Down Expand Up @@ -242,7 +243,7 @@ trait OAuth2Provider extends SocialStateProvider with OAuth2Constants with Logge
ClientID -> Seq(settings.clientID),
ClientSecret -> Seq(settings.clientSecret),
GrantType -> Seq(AuthorizationCode),
Code -> Seq(code)) ++ settings.accessTokenParams.mapValues(Seq(_)) ++ redirectParam.toMap.mapValues(Seq(_))
Code -> Seq(code)) ++ settings.accessTokenParams.transformValues(Seq(_)) ++ redirectParam.toMap.transformValues(Seq(_))
httpLayer.url(settings.accessTokenURL).withHttpHeaders(headers: _*).post(params).flatMap { response =>
logger.debug("[Silhouette][%s] Access token response: [%s]".format(id, response.body))
Future.fromTry(buildInfo(response))
Expand Down
4 changes: 4 additions & 0 deletions silhouette/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ libraryDependencies ++= Seq(
)

enablePlugins(PlayScala, Doc)

unmanagedSourceDirectories in Compile += {
baseDirectory.value / (if(Util.priorTo213(scalaVersion.value)) "app-2.13-" else "app-2.13+")
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.mohiva.play.silhouette.api.util.{ ExtractableRequest, MockHTTPLayer,
import com.mohiva.play.silhouette.impl.exceptions.{ AccessDeniedException, UnexpectedResponseException }
import com.mohiva.play.silhouette.impl.providers.OAuth2Provider._
import com.mohiva.play.silhouette.impl.providers.state.UserStateItem
import com.mohiva.play.silhouette.ScalaCompat._
import org.specs2.matcher.ThrownExpectations
import org.specs2.mock.Mockito
import org.specs2.specification.Scope
Expand Down Expand Up @@ -250,7 +251,7 @@ abstract class OAuth2ProviderSpec extends SocialStateProviderSpec[OAuth2Info, So
ClientID -> Seq(c.oAuthSettings.clientID),
ClientSecret -> Seq(c.oAuthSettings.clientSecret),
GrantType -> Seq(AuthorizationCode),
Code -> Seq("my.code")) ++ c.oAuthSettings.accessTokenParams.mapValues(Seq(_)) ++ redirectParam.toMap.mapValues(Seq(_))
Code -> Seq("my.code")) ++ c.oAuthSettings.accessTokenParams.transformValues(Seq(_)) ++ redirectParam.toMap.transformValues(Seq(_))
implicit val req = FakeRequest(GET, "?" + Code + "=my.code")
wsRequest.withHttpHeaders(any) returns wsRequest

Expand Down

0 comments on commit 174b74f

Please sign in to comment.