Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Use Crowd authentication with JRJC

Matt Tucciarone July 31, 2013

Before we jump into the problem, here's the layout of the Java application:

  • JRJC add-on to perform functions such as creating, editing, and resolving issues
  • Spring Security that authenticates with a local CROWD

Currently, JRJC fully supports basic authentication and this was being used before the introduction of Spring Security. As I'm not a complete expert on REST, I would like the following scenario to occur:

Connect to JIRA with JRJC using the CROWD credentials that Spring Security authenticates with.

While JRJC has stated that other means to authentication will be added soon, I would like to know if this scenario is being considered and if it isn't, how would I go about performing this authentication?

Thanks!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Matt Tucciarone August 4, 2013

I ended up setting up SSO in my application when it does the Spring Security authentication and then I use the cookie that is generated and wrap it into a request inside my own AuthenticationHandler. This works beautifully well. If anyone has any better suggestions, let me know!

Matt Tucciarone August 11, 2013

Note that this works strictly for localhost, but if you want to set it up for a specific SSO Domain, you'll need to pass an "X-Forwarded-To" Header in the request wrapped inside your custom AuthenticationHandler. Just a head's up for those who are interested

Nate Jones April 18, 2014

Hey Matt,

Any chance you could give me an idea what I'm doing wrong here?

RestCrowdClientFactory factory = new RestCrowdClientFactory();
CrowdClient client = factory.newInstance("http://localhost:8095/crowd", "crowd-auth-webapp", "password");
UserAuthenticationContext userAuthCtx = new UserAuthenticationContext();
userAuthCtx.setName("test");
userAuthCtx.setCredential(new PasswordCredential("test"));
userAuthCtx.setApplication("crowd-auth-webapp");
userAuthCtx.setValidationFactors(new ValidationFactor[0]);
final String token = client.authenticateSSOUser(userAuthCtx);
JiraRestClientFactory jiraFactory = new com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory();
JiraRestClient jira = jiraFactory.create(new URI("http://localhost:8080"), new AuthenticationHandler(){
  public void configure(com.atlassian.httpclient.api.Request request){
    request.setHeader("Cookie", cookieConfig.getName() + "=" + token);
  }
});
ProjectRestClient projects = jira.getProjectClient();
for(BasicProject project : projects.getAllProjects().get()){
  System.out.println(project.getName());
}

When I run this the Crowd client portion executes fine, and the user token gets set. But when I call the jira client it says that I'm not authenticated. Any suggestions?

Thanks!

TAGS
AUG Leaders

Atlassian Community Events