Giter VIP home page Giter VIP logo

Comments (13)

jrrl avatar jrrl commented on August 14, 2024

Okay, I just tested it again, and weirdly enough, if I call Request#body in a before filter before I add the security filter, it works perfectly.

before("/api/users/*", (request, response) -> log.debug("Request body: {}", request.body())); <-- call Request#body before the security filter
before("/api/users/*", new SecurityFilter(config, "HeaderClient", "admin"));
post("/api/users", (request, response) -> {
    log.debug("Request body: {}", request.body()); // will now work properly
   // ... do something
});

from spark-pac4j.

leleuj avatar leleuj commented on August 14, 2024

This is really strange. I will do some tests.

from spark-pac4j.

leleuj avatar leleuj commented on August 14, 2024

I cannot reproduce the issue. I updated the demo with the /body endpoint: pac4j/spark-pac4j-demo@bebf055

I use a HeaderClient like you:

HeaderClient headerClient = new HeaderClient("Authorization", (credentials, ctx) -> {
  final String token = ((TokenCredentials) credentials).getToken();
  if (CommonHelper.isNotBlank(token)) {
    final CommonProfile profile = new CommonProfile();
    profile.setId(token);
     credentials.setUserProfile(profile);
  }
});
before("/body", new SecurityFilter(config, "HeaderClient"));
post("/body", (request, response) -> {
    logger.debug("Body: " + request.body());
    return "done: " + getProfiles(request, response);
});

I send a body and an Authorization header and the body is displayed in the logs while the authentication works.

Can you test my demo and tell me if it works for you? Just to try to pinpoint where the issue is.

from spark-pac4j.

jrrl avatar jrrl commented on August 14, 2024

Hi, I checked out the demo and tried out the code you used, and it's still returning blank for me. I even ran it with the debugger and when I looked inside the request object, and it was null.

Log files:
SPARK PAC4J DEMO 21:47:25.930 [qtp1530621925-17] DEBUG org.pac4j.demo.spark.SparkPac4jDemo - Body:

from spark-pac4j.

leleuj avatar leleuj commented on August 14, 2024

OK. Even stranger. Can you give me details about your environment? OS? Java version? ...

from spark-pac4j.

jrrl avatar jrrl commented on August 14, 2024

I'm running Windows 7, java version = 1.8.0_45. I ran the code using both IntelliJ and through the command line and they both say the same thing. I'll try doing it tomorrow in a different computer, maybe my environment really is the cause.

from spark-pac4j.

leleuj avatar leleuj commented on August 14, 2024

I'm using MacOS. I wish it could explain the issue, but it seems somehow unlikely. Keep me posted...

from spark-pac4j.

leleuj avatar leleuj commented on August 14, 2024

BTW, can you test the new version 2.0.0-RC2-SNAPSHOT to test if you've got the same problem?

from spark-pac4j.

jrrl avatar jrrl commented on August 14, 2024

Is the 2.0.0-RC2 snapshot available on maven? I only see the RC1 snapshot when I check mvnrepository

from spark-pac4j.

leleuj avatar leleuj commented on August 14, 2024

In the Sonatype snapshots repository in fact: https://github.com/pac4j/spark-pac4j-demo/blob/master/pom.xml#L10

from spark-pac4j.

leleuj avatar leleuj commented on August 14, 2024

Any update on this? I'm releasing the 2.0.0-RC2 version if you want to do new tests...

from spark-pac4j.

leleuj avatar leleuj commented on August 14, 2024

No feedback. Considered solved. Closing

from spark-pac4j.

buckelieg avatar buckelieg commented on August 14, 2024

It is still in a way. With indirecti form client at least :(

from spark-pac4j.

Related Issues (18)

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.