Code Monkey home page Code Monkey logo

jwt's People

Contributors

chris-rudmin avatar eecolor avatar iain-logan avatar jotsif avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jwt's Issues

Support for RS256

Hi,
would you be interested in PR which contains support for RS256?

Aud with a Seq[String]

An exception or error caused a run to abort: play.api.libs.json.JsArray.(Lscala/collection/Seq;)V
java.lang.NoSuchMethodError: play.api.libs.json.JsArray.(Lscala/collection/Seq;)V
at io.igl.jwt.Aud.(Claims.scala:41)
at io.igl.jwt.Aud$.apply(Claims.scala:47)
....

Hello i have used your library and i am trying to pass a Seq[String] to the aud claim but the above error appears, i have tried with play json 2.6.0.

def createTokenWithRole(userName: String, role: Seq[String]): String = { val jwt = new DecodedJwt(Seq(Alg(Algorithm.HS256), Typ("JWT")), Seq(Iss(userName), Aud(role))) jwt.encodedAndSigned(secretKey) }

using scala 2.12.3

with dependencyOverrides ++= Set("com.typesafe.play" %% "play-json" % "2.6.7")
in my sbt file it works

Optional private claims

The current implementation does not cater for optional claims.

As a result of the exchange that occurred in #2 , the conclusion was drawn that support for optional claims is in fact desirable. As such, they will be implemented.

In the mean time, in #2 @luksow demonstrates a workaround that shows how optional claims can be achieved currently.

ES256 support

ES256 is one of the algorithms recommended for support by JWT implementations, it would be fantastic if we could use it here.

Update documentation: no need to include play-json in own build.sbt

You will need to add play-json as a dependency to your project when using private fields. Do this by adding the below line to your build.sbt file.

libraryDependencies ++= Seq("com.typesafe.play" %% "play-json" % "2.4.0")

It seems this library is already included in your build.sbt:

libraryDependencies ++= Seq(
  "com.typesafe.play" %% "play-json" % "2.4.0",
  "commons-codec" % "commons-codec" % "1.10",
  "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
)

Nice library btw :-)

Unify the way character encoding is selected

There is a discrepancy between the encoding and decoding of JWT's when it comes to character encoding.

Encoding is always done in UTF-8, decoding however defaults to UTF-8 but can be set to other supported character encodings.

Some type that represents the character encoding to use will be created, an instance of which will be optionally provided when decoding and encoding a JWT. If no such argument is provided, we default to UTF-8.

decoding utf-8 claims

Hi,

The method DecodedJwt.validateEncodedJwt seems to handle utf-8 characters in the token incorrectly, decoding to the default character encoding instead.

I'm not sure, but I think the private def decodeBase64 here needs a "UTF-8" argument for the new String creation.

It would be even nicer for other people to have an option of what character encoding to use. But just utf-8 would be nice enough for me.

Thank you :)

Optional private claims

Hi,

I have problems implementing claims that are private and optional. What's preferred way of doing it?

If I put them on required list, validation fail if they're missing. If I put them on ignoredList, they don't appear in decoded token.

Thanks!

Is the RS256 implementation complete/correct?

It looks like validateEncodedJwtWithEncodedSecret calls encodedSignature which ends up calling j.s.Signature.sign; this value is compared literally with the input signature value. This does not match the description of RS256 from the JWA spec:

Submit the JWS Signing Input, the JWS Signature, and the public key corresponding to the private key used by the signer to the RSASSA-PKCS1-V1_5-VERIFY algorithm using SHA-256 as the hash function.

I believe RSASSA-PKCS1-V1_5-VERIFY here corresponds to j.s.Signature.verify. The corresponding test that came with #14 should also be updated to use the public key part for verification.

Ignore Unknown Claim

I've encounter a issue today with the library and unknown claim that is a bit related to #2 and #4.
The new Draft of JWT(https://tools.ietf.org/html/draft-ietf-oauth-amr-values-03) that came out last week add a new claim that have already been implemented by major vendor, namely auth0.

Suddenly all my api were rejecting a valid JWT token, which is not something that I would expect.

According to the specification unknown claim should be ignored (https://tools.ietf.org/html/rfc7519) :

The set of claims that a JWT must contain to be considered valid is
context dependent and is outside the scope of this specification.
Specific applications of JWTs will require implementations to
understand and process some claims in particular ways. However, in
the absence of such requirements, all claims that are not understood
by implementations MUST be ignored.

Is It something that you were aware?

Support for scala 2.12.x

This library can be used at the environment of scala 2.12.x?
When I tried to build a sample application with this lib, It can't be loaded from build.sbt file.
Is there any solution or any plan to support 2.12.x?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.