Comments (13)
Interestingly,
import pdi.jwt.JwtSession._
fixed the issue
from jwt-scala.
+1 Have the same issue in Intellij IDEA... The code compiles via command line by "sbt compile" but in IDE it throws compiling errors...
UPDATE: I fixed it by adding "JwtPlayImplicits" trait (https://github.com/pauldijou/jwt-scala/blob/master/play/src/main/scala/JwtPlayImplicits.scala) for actions and my project started to compile in IntelliJ IDEA also
from jwt-scala.
If using 0.12.x, that's because all implicits have been moved inside their respective object. See changelog
from jwt-scala.
Play 2.4? Compile time error? Did you checked the import to be sure to have all needed implicits in the scope? Try import pdi.jwt._
.
from jwt-scala.
Yeah sorry, Play 2.4, compile time errors.
Btw I already had that, this is the file that gets that jwtSession error:
package controllers
import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits._
import play.api.mvc._
import play.api.mvc.Results._
import play.api.libs.json._
import pdi.jwt._
import models.User
class AuthenticatedRequest[A](val user: User, request: Request[A]) extends WrappedRequest[A](request)
trait Secured {
def Authenticated = AuthenticatedAction
}
object AuthenticatedAction extends ActionBuilder[AuthenticatedRequest] {
def invokeBlock[A](request: Request[A], block: AuthenticatedRequest[A] => Future[Result]) =
request.jwtSession.getAs[User]("user") match {
case Some(user) => block(new AuthenticatedRequest(user, request)).map(_.refreshJwtSession(request))
case _ => Future.successful(Unauthorized)
}
}
from jwt-scala.
By randomly
, do you mean it works sometime? Your code looks just fine... not sure what I can do about potential SBT problems... There is no reason for code which compile not to compile anymore if nothing changed.
Did you tried to reproduce with the play-angular-standalone
application inside this repo? You could downgrade it to Play 2.4 and JWT Scala 0.5.1 and try to add your own stuff until it breaks.
from jwt-scala.
I mean that sometimes it doesn't work on intellij startup, after one or two SBT refresh it works fine, And I'm having this issue since I've added jwt-play. I'll do that way when I've some free time, I'll close this for now. Thank you
from jwt-scala.
I'm still having this issue. It is indeed intermittent and it's not an issue with SBT compiling it's IntelliJ. It works when building with sbt command line, but not when built with IntelliJ. It must have something going on with implicits.
from jwt-scala.
I was having this issue with IntelliJ too, so I decided to test it out with Ensime on various other editors and the same issue persists and replicates on other IDEs and Text Editors (such as Atom).
Not really sure what is the issue here is either so I can't sadly help with that.
from jwt-scala.
But does the project compile and works fine using SBT cli?
from jwt-scala.
@pauldijou yeah, it compiles just fine and the example application does work.
from jwt-scala.
Hello, I'm having the same problem. My application compiles fine using SBT, but IntelliJ IDEA shows errors when calling the .jtwSession method on the request object.
This is also the case with the play-angular-standalone project. I downloaded this project and imported it into IntelliJ IDEA, and there too IDEA does not recognize the .jwtSession method on the request object, even thought SBT compiles and runs the project without problems.
Has anyone found a solution for this yet? Thanks,
from jwt-scala.
Hi @pauldijou Im having this same error with play 2.5.13.
from jwt-scala.
Related Issues (20)
- Add zio-json usage documentation
- com.fasterxml.jackson.databind.JsonMappingException: Scala module 2.11.4 requires Jackson Databind version >= 2.11.0 and < 2.12.0 HOT 10
- 9.1.1 changelog? HOT 2
- zio-json partially missing in the docs
- com.fasterxml.jackson.databind.JsonMappingException: Scala module 2.11.4 requires Jackson Databind version >= 2.11.0 and < 2.12.0 HOT 2
- Why does JwtCirce.decode lead to java.time.Clock validating the expiration? HOT 3
- [Question] Support for Base64 url encoded keys HOT 1
- [Question] Lookup the algorithm from the token
- fix scala-js build HOT 5
- Ed25519 is not the correct JSON Web Algorithm name
- parseKey does not work with keys stored in AWS secrets manager
- Version 9.4.0 is not compatible with Scala 3.2.2 HOT 6
- New release? HOT 3
- scala.js compatibility
- Incorrect Regex for JTI and ISS
- Play 3.x support for `jwt-play` HOT 2
- Scala3 Support for jwt-play HOT 1
- scala-jwt 9.4.5 contains a major breaking change HOT 1
- com.fasterxml.jackson.databind.JsonMappingException: Scala module 2.14.3 requires Jackson Databind version >= 2.14.0 and < 2.15.0 - Found jackson-databind version 2.15.0 HOT 1
- JWKS? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jwt-scala.