Comments (13)
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.
This is really strange. I will do some tests.
from spark-pac4j.
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.
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.
OK. Even stranger. Can you give me details about your environment? OS? Java version? ...
from spark-pac4j.
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.
I'm using MacOS. I wish it could explain the issue, but it seems somehow unlikely. Keep me posted...
from spark-pac4j.
BTW, can you test the new version 2.0.0-RC2-SNAPSHOT to test if you've got the same problem?
from spark-pac4j.
Is the 2.0.0-RC2 snapshot available on maven? I only see the RC1 snapshot when I check mvnrepository
from spark-pac4j.
In the Sonatype snapshots repository in fact: https://github.com/pac4j/spark-pac4j-demo/blob/master/pom.xml#L10
from spark-pac4j.
Any update on this? I'm releasing the 2.0.0-RC2 version if you want to do new tests...
from spark-pac4j.
No feedback. Considered solved. Closing
from spark-pac4j.
It is still in a way. With indirecti form client at least :(
from spark-pac4j.
Related Issues (18)
- SAML Protocol not working HOT 12
- RequiresAuthenticationFilter: Doc/Impl wrong; empty clientName HOT 3
- Upgrade to pac4j v1.9 HOT 1
- Always force halting for actions when the access is not granted HOT 1
- Add a getSparkRequest method in the SparkWebContext
- Upgrade to pac4j v2.0
- Question on authn failures with LoginForm
- ClassNotFound - ClassLoader HOT 3
- SecurityFilter wipes out request body HOT 12
- Question on implementation of SecurityFilter HOT 1
- Upgrade to pac4j v3
- SAML message intended destination endpoint ERROR HOT 11
- DIGEST authentication for sparkjava HOT 2
- Dependency Dashboard
- Don't deploy PR on Sonatype HOT 1
- Upgrade to spark-core 2.3, Java 7 HOT 1
- Upgrade to pac4j v1.8.2 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 spark-pac4j.