Before we jump into the problem, here's the layout of the Java application:
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!
Community moderators have prevented the ability to post new answers.
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.