I have crowd running on apache, where apache is authorising our users based on their certificates.
Is there a way that I can get around the need for a user to login with their username and password as they are already trusted at this point?
I could just pass the user's name from the cert
Would I need to write a plugin to do this? If so, what kind?
TLDR: I want to remove user validation as I already trust my users based on their certs.
You will actually need to write some code but it is quite straight forward. Crowd's REST API allows you to authenticate a user without validating the password by setting the validate-password parameter to false when creating a new SSO token.
Please take a look at the REST API reference: https://docs.atlassian.com/atlassian-crowd/latest/REST/#usermanagement/1/session-authenticateUser
Then, all you need to do is add the newly created SSO token to your client's HTTP requests.
What kind of plugin do you think would be best suited to implement a call out to the REST API?
I was thinking servlet filter as it allows you to make use of the before-dispatch option.
However, this will be my first plugin to develop so I'm not 100% on where I should start.
I do agree with you, this is what servlet filters are made for! But you'll have to add the SSO token as a Crowd cookie at the beginning of the filter chain so the value of the location parameter should be before-login.
(If not already done, please check Atlassian's documentation at https://developer.atlassian.com/display/CROWDDEV/Servlet+Filter+Module)
To create the SSO token is it as simple as grabbing the token from this API call? -
and in terms of adding the token as a crowd cookie, do we need to use an API to add it?
This is all really helpful, thanks again
Bit of a delay in replying.. But one more question.
I have the plugin working and am able to do a POST to authenticate the user and generate a token. I then add the token to the crowd.token_key cookie as you said above.
However, I am seeing two cookies now, both crowd.token_key, my one and another random one.
I'm applying the filter to url /console/login.action, but it always prompts me to log in, and then pushes me back to the login page again.
Basically I think the crowd cookie isn't being applied in all the right places, instead the other cookie i mentioned is.
Any ideas on how to set the cookie in all the places I need?
I'm not sure about what's going on here, I mean getting a second Crowd cookie. I suggest that you set the log level of com.atlassian.crowd to DEBUG in Settings > Logging & profiling > Logging so as to understand why your first cookie does not seem to be taken into account here (this might have something to do with the validation factors).
You might also be right about the cookie's path and need to explicitly set it to "/", something like:
Cookie crowdCookie = new Cookie("crowd.token_key", crowdSSOToken); crowdCookie.setPath("/"); crowdCookie.setHttpOnly(true); crowdCookie.setMaxAge(-1); request.addCookie(crowdCookie);
I also think you should apply the filter to "/console/*", not just "/console/login.action" which is already a redirection URL (since your plugin makes you get a valid Crowd cookie you shouldn't be redirected to the login form).
Also wondering if it makes sense to use this class to do the work for me?
method - authenticateWithoutValidatingPassword seems to authenticate and add the token to the response/request on its own.
This guy uses it as an example
I'll look at doing this tomorrow, will post back
Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events