Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get authentication context(cookie or header) in my java main function? #666

Open
sss0350 opened this issue Jan 24, 2018 · 3 comments

Comments

@sss0350
Copy link

sss0350 commented Jan 24, 2018

Hello there,
I'm trying to figure out how to I use iron-functions to get client cookie or header information(token) from my java class. Could you give me an example? (can't find one at current code track)
At old time we will get httprequest / httpresponse object from servlet in web a standard web project.
And try to get cookie and header there, just wondering how do we get from a pojo main function here?
Since we will use cookie(entrypt) to do user verification with our other systems.
Thank you!
Gatsby

@sss0350 sss0350 changed the title How do I get authentication context in my java main function? How do I get authentication context(cookie or header) in my java main function? Jan 24, 2018
@c0ze
Copy link
Contributor

c0ze commented Jan 25, 2018

hello @sss0350 ,

All headers should be available as ENV variables in your function, with the following format :

HEADER_{HTTP Header, uppercase, `-` replaced by `_`}
HEADER_ACCEPT_LANGUAGE
HEADER_AUTHORIZATION

etc.

functions inputs

Hope this helps !

@sss0350
Copy link
Author

sss0350 commented Jan 25, 2018

Hey @c0ze,

I can get http header with System.getenv("HEADER_X") in java as you provided.

But how to I get cookies values ? I can't find a way to get it , since we need to rely on cookie to do some authorization. Could you give me a hint?

@c0ze
Copy link
Contributor

c0ze commented Jan 26, 2018

hello @sss0350 !

I'm glad that you were able to access request headers ! You can use route configuration to add static headers as described here. Unfortunately there is no way to add headers dynamically at this point as you would need to in a cookie based authentication. What you can do is maybe write / add a server cookie to response object, and read it from the body (as opposed to from headers) from the client side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants