aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlad <vlad@driver.xyz>2017-03-24 22:14:47 -0700
committervlad <vlad@driver.xyz>2017-03-24 22:14:47 -0700
commitb97bc7242d1686a303f6366755652b6bf93e3851 (patch)
tree45ba06837b85738afb34d84a6c9988b157a1314f
parent244691b58a233b2e4c7042742230245c539fea3d (diff)
downloaddriver-core-b97bc7242d1686a303f6366755652b6bf93e3851.tar.gz
driver-core-b97bc7242d1686a303f6366755652b6bf93e3851.tar.bz2
driver-core-b97bc7242d1686a303f6366755652b6bf93e3851.zip
PDW-238 Session validity verification support for `AuthProvider`
-rw-r--r--src/main/scala/xyz/driver/core/rest.scala6
-rw-r--r--src/test/scala/xyz/driver/core/AuthTest.scala4
2 files changed, 5 insertions, 5 deletions
diff --git a/src/main/scala/xyz/driver/core/rest.scala b/src/main/scala/xyz/driver/core/rest.scala
index dd43989..42ffac4 100644
--- a/src/main/scala/xyz/driver/core/rest.scala
+++ b/src/main/scala/xyz/driver/core/rest.scala
@@ -132,16 +132,16 @@ package rest {
* Specific implementation on how to extract user from request context,
* can either need to do a network call to auth server or extract everything from self-contained token
*
- * @param context set of request values which can be relevant to authenticate user
+ * @param ctx set of request values which can be relevant to authenticate user
* @return authenticated user
*/
- def authenticatedUser(context: ServiceRequestContext): OptionT[Future, U]
+ def authenticatedUser(implicit ctx: ServiceRequestContext): OptionT[Future, U]
/**
* Specific implementation can verify session expiration and single sign out
* to verify if session is still valid
*/
- def isSessionValid(user: U)(context: ServiceRequestContext): Future[Boolean] = Future.successful(true)
+ def isSessionValid(user: U)(implicit ctx: ServiceRequestContext): Future[Boolean] = Future.successful(true)
/**
* Verifies if request is authenticated and authorized to have `permissions`
diff --git a/src/test/scala/xyz/driver/core/AuthTest.scala b/src/test/scala/xyz/driver/core/AuthTest.scala
index c39d9da..e6025fb 100644
--- a/src/test/scala/xyz/driver/core/AuthTest.scala
+++ b/src/test/scala/xyz/driver/core/AuthTest.scala
@@ -31,8 +31,8 @@ class AuthTest extends FlatSpec with Matchers with MockitoSugar with ScalatestRo
}
val authStatusService = new AuthProvider[User](authorization, NoLogger) {
- override def authenticatedUser(context: ServiceRequestContext): OptionT[Future, User] = OptionT.optionT[Future] {
- if (context.contextHeaders.keySet.contains(AuthProvider.AuthenticationTokenHeader)) {
+ override def authenticatedUser(implicit ctx: ServiceRequestContext): OptionT[Future, User] = OptionT.optionT[Future] {
+ if (ctx.contextHeaders.keySet.contains(AuthProvider.AuthenticationTokenHeader)) {
Future.successful(Some(BasicUser(Id[User]("1"), Set(TestRole))))
} else {
Future.successful(Option.empty[User])