package org.scalatra.example
import org.scalatra.auth.strategy.{BasicAuthStrategy, BasicAuthSupport}
import org.scalatra.auth.{ScentrySupport, ScentryConfig}
import org.scalatra.{ScalatraBase}
class OurBasicAuthStrategy(protected override val app: ScalatraBase, realm: String)
extends BasicAuthStrategy[User](app, realm) {
protected def validate(userName: String, password: String): Option[User] = {
if(userName == "scalatra" && password == "scalatra") Some(User("scalatra"))
else None
}
protected def getUserId(user: User): String = user.id
}
The compiler spit out the following error:
sbt:e-liberate> compile
[info] Compiling 6 Scala sources to /Users/dolan/e-liberate/target/scala-2.12/classes ...
[error] /Users/dolan/e-liberate/src/main/scala/com/github/dmurvihill/eliberate/AuthStrategy.scala:27:7: class OurBasicAuthStrategy needs to be abstract, since:
[error] it has 2 unimplemented members.
[error] /** As seen from class OurBasicAuthStrategy, the missing signatures are as follows.
[error] * For convenience, these are usable as stub implementations.
[error] */
[error] protected def getUserId(user: com.github.dmurvihill.eliberate.User)(implicit request: javax.servlet.http.HttpServletRequest,implicit response: javax.servlet.http.HttpServletResponse): String = ???
[error] protected def validate(userName: String,password: String)(implicit request: javax.servlet.http.HttpServletRequest,implicit response: javax.servlet.http.HttpServletResponse): Option[com.github.dmurvihill.eliberate.User] = ???
[error] class OurBasicAuthStrategy(protected override val app: ScalatraBase, realm: String)
[error] ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
Adding the implicit parameter lists to the offending method definitions fixed the problem.
As a separate issue, copying and pasting the method signatures as stubs into my source file did not work as advertised, since Scala tolerates only one "implicit" keyword at the start of the parameter list, and the "stub" includes it before each parameter.
sbt 1.1.4
Scala 2.12.6
Scalatra 2.6.3
scalatra-auth 2.6.3