-
Notifications
You must be signed in to change notification settings - Fork 640
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
OAuth2 not working : Authentication failure #946
Comments
This feature is really hard to troubleshoot because it depends on the authentication platform APIs. when the Federated Identity platform redirects to TheHive login page, do you see the code on the URL? From there, TheHive will call the What do you see in your browser's console after redirection to login page? |
Hi @nadouani, Thank you for such a quick answer. I do receive a code in the URL https://my-hive-instance.com/index.html#/login?code=[received_code]. Unfortunately, I do not see much information when being redirected in my browser's console. Before logging on with SSO, on the url https://my-hive-instance.com/index.html#/login, I see these two errors. Once I sign in with sso, successfully login on fedid page and get redirected with a code, Here is a screenshot I may have given some more information at this link already but I am not sure that it gives much more. |
What's the details required by the If TheHive doesn't call that API as expected then in fact it you will not be able to get the token, and then 401 is your response. |
To validate the code and the token, a POST request should be sent to
The response type is as such with a JSON:
Then I can just GET the You are right, TheHive is not calling the API at all from what I see. |
I think that TheHive calls the tokenUrl with an « Authorization: token AUTHORIZATION_TOKEN » header, not with a basic auth. |
Hi @nadouani, Thank you a lot for helping me troubleshooting this issue. I am going to take a look and see if I can conform to what TheHive expects on my side. (an authorization token) I'll keep you updated once I get further news. |
Here are the details of how the oauth apis are called: PS: it's scala, good luck :p |
Actually, I've been looking at the code and the OAuth2Srv.scala seems fine to me. From what I see and understand, it looks like it works the way I expect it and waits to catch the code to then use the Bearer Access Token to retrieve user informations. However, I am never going inside So I suppose the OAuth2 service manages to successfully redirect me to the In the end, this leaves the client with an empty header. Hence why I get I do not get any further logs apart from Could this be considered a bug? Maybe there are some prerequisites parameters to add in the application.conf that I missed or weren't explicitly documented. I've tried commands such as |
For sure, the oauth feature can be improved by adding more configuration options, because each oauth service implement its own way of things. There is no standard way. If you have ideas of options we can add, then your welcome ;). I would consider that as an improvement. |
Just as an update for transparency, in case anybody else is following the issue, I've enabled DEBUG logging by adding
Still no signs of |
Hey @softybear! As I worked on the OAuth2 feature a while ago, I'll try to have a look on the issue one of these days, maybe I can clarify the situation. |
Hi @saibot94, Thank you so much for jumping in, I am looking forward to hear your input on the issue! |
Hi @softybear, Could you try to configure TheHive and your IDP to redirect you to |
Hi @1earch, Thank you for your input! I haven't fixed my problem with SSO. So, the redirect works, I can login on the IDP and then I am redirected back to thehive instance. I do get an authorization code in the url. From this step, then, nothing happens. No log, no network request, nothing.
I think I just didn't manage to get the application.conf right. Have you managed to make oauth2 authentication work on your side? I'm willing to put some more efforts to make it work! :)) EDIT : I've just seen you've worked on the issue and provided many additionnal features. Thank you for your work and I cannot wait to test it! |
Could you try to configure your
Note: you may need to reconfigure your IDP to allow this redirect URI. |
Hi @1earch, On current latest thehive version (3.3.0), it seems like it doesn't work for me. Here are the logs :
The first authentication failure seems to happen in any cases where I am not logging in. (Might not be SSO/OAuth2.0 related) My config is as such :
With the redirectUri configured as you said, it still works and I do get a token : Surprisingly, I've noticed after some time that a POST request from |
Concerning your logs:
This could be normal: you aren't logged in, but the UI (frontend) seems trying to access to a protected resource ( For the other errors:
The first debug message explain that authentication by API key doesn't support SSO authentication (logical). The second one explain that authentication using local credentials doesn't support neither SSO. Finally, the real SSO authentication service is called, and TheHive "gets user token with the code from the response". Thus, all of this seems normal for me. Can you confirm that modifying the |
In addition, your token endpoint waits for a POST request to tokenUrl using Basic Auth:
but TheHive's implementation doesn't support this. The request will be:
Thus, I think you need to configure your token endpoint to accept request without HTTP basic auth. Then, could you try to get access token (with curl) then user infos using this second format? If this work, it may work with TheHive 😉 |
I confirm that modifying the redirectUri caused the last debug message.
this is what I get with Getting rid of You are actually so right about what my endpoint expects, I didn't know TheHive would make the request that way. You just troubleshooted my issue so well, thanks a lot!
I am right now taking actions to fix this, this is clearly a problem linked to my environment and hopefully the administrator can comply to these requests! |
I may have opened a duplicate of this issue yesterday - #1294 . Like @softybear, my IDP only allows HTTP Basic authentication at the token URL. Is that ultimately the fix here? If so, I think it's only a few lines of code to add a configuration option and an if statement that toggled between Bearer and Basic. |
Hi @hkelley, I haven't looked up in the issue for SSO since then, but in the end thanks to @1earch, I found out that the main blocking point was the redirect URI. My company's IdP doesn't support redirect uri with '#' characters and I guess it's the same for you. I've seen some ways documented by @1earch I haven't checked for the new 3.4.1 yet, but it implements léarch's code and improved SSO, maybe it fixes that. Edit : I also discovered that my company's IdP also accepted both Bearer and Basic Auth, even though only one was documented. |
having similar issues.. version 3.4.2-1 authing with OIDC sends me to the following, provides the code, says authenticated but i'm always sent back to the hive login screen, where i auth with my identity provider credentials, and i get
if i enable autologin, i get sent into an infinite loop of it authing and sending me to the login page i've tried redirect URIs for index.html, with and without the #!/login config:
|
Hello folks, this looks like a hot and active issue. Can anyone here provide us:
The foal here is to help us debug the issue :) |
And of course, we talk about TheHive 3 here, right? |
My issue is not the same as @shortstack's but I may be able to help set up a sandbox. @nadouani , how can we DM some URLs and credentials? I dropped an email to the contact@ address I found in your github profile. |
fusionauth has a really simple one line install on linux, https://fusionauth.io/docs/v1/tech/5-minute-setup-guide, if anyone is interested i've got it working with other integrations via oidc, and would love to get thehive working with it. it's so close! |
this might be helpful, or shed some light on where the disconnect might be - FusionAuth/fusionauth-issues#620 (comment) |
Request Type
Bug
Work Environment
Problem Description
Using @saibot94 's OAuth2.0 and SSO implementation, TheHive fails to log in and/or create account using OAuth2.0.
The configuration in the application.conf is as such :
Once I click on "Sign in with SSO", I am well redirected to the Federated Identity platform and can successfully login. Once I'm logged on, it brings me back to thehive's login page. I do get a code in the url which works sucessfully in postman.
However, on the client side, nothings happens and I am left with these logs.
Steps to Reproduce
Complementary information
TheHive is running as HTTP. I did not set up SSL nor reverse proxy on the server.
From an authorization code grant flow point of view :
Redirect : OK
Authorization code request & response : OK
Exchange code for Access Token : No logs or requests to the Token Url
Call API with Access Token : No logs, or requests about it
Am I missing some steps in order to successfully implement OAuth2.0 and SSO?
Maybe the configuration of the
application.conf
is not right also?Thank you so much for your help,
softybear
The text was updated successfully, but these errors were encountered: