How to login without password (token-based) into confluence 6.8 from crowd SSO ?
Asked by hamed_hatami:

Hi there,

I want to login into confluence 6.8 from my web application without password

actually, I need to login into confluence by username only

I can get the user token from rest api but when i put the user token in cookie and return back to confluence , nothing happened

I have integrated confluence with Crowd and I have activated the SSO but I don't know how can I use crown in my web application ??

Is there any easy solution to login ???

My email address : hamedhatami2012@gmail.com

Regards,

Hamed Hatami


Answers:
author: hamed_hatami
body: This is a snipet of code to getting token from crowd and then I should goto confluence or jira from inside of my web application that is based on Java EE 7 :

public static String getToken(String propertyName, String username, String password) throws Exception {  
String token = "";  
Properties crowd_props = new Properties();  
crowd_props.load(CrowdClientUtil.class.getClassLoader().getResourceAsStream("/" + propertyName.trim()));  
ClientProperties clientProperties = ClientPropertiesImpl.newInstanceFromProperties(crowd_props);  
CrowdClient crowdClient = new com.atlassian.crowd.integration.rest.service.factory.RestCrowdClientFactory().newInstance(clientProperties);  
/\* CrowdHttpAuthenticator crowdHttpAuthenticator = new CrowdHttpAuthenticatorImpl(crowdClient,  
clientProperties,  
CrowdHttpTokenHelperImpl.getInstance(  
CrowdHttpValidationFactorExtractorImpl.getInstance()));\*/  
UserAuthenticationContext userAuthenticationContext = new UserAuthenticationContext();  
userAuthenticationContext.setName(username);  
userAuthenticationContext.setCredential(new PasswordCredential(password, false));  
ValidationFactor\[\] factors = new ValidationFactor\[\]{  
new ValidationFactor("remote_address", "127.0.0.1"),  
new ValidationFactor("X-Forwarded-For", clientProperties.getApplicationAuthenticationURL())  
};

userAuthenticationContext.setValidationFactors(factors);  
userAuthenticationContext.setApplication(clientProperties.getApplicationName());

token = crowdClient.authenticateSSOUserWithoutValidatingPassword(userAuthenticationContext);

return token;  
}

Actually I also have crowd.property file in my web application and client crowd jar file to access


author: hamed_hatami
body: I have changed the "seraph-config.xml" file in (confluence and jira) side to use sso authenticator instead of simple authenticator and then I have created many users and groups with specific access rights to a specific directory in crowd side and import the users and groups from (confluence and jira) into crowd and in (confluence and jira), I have set the correct groups and users into specific user directory and WhiteList has been created too although I have created application link to connect all of them together so I need connect as sso like into crowd and then go to confluence or jira without login (token-based) easily and actually do everything from my web application programmatically and I should have access to crowd from my web application by client api or rest invocation and then with some doing task that you should specify for me , i should go directly into confluence or jira,

I have read the documents of crowd and confluence / jira and there is not step by step and clear document about how to exactly configured or there is not an clear example on github ....

I have got stucked in this problem and I need to give me a hand ASAP.

Thanks in advance


author: hamed_hatami
body: As a matter of fact, my web application is a client of crowd and I can get token from crowd but I need an exact example of parameter should set into confluence url to authenticated correctly, and directly goes to confluence in my web application response


author: hamed_hatami
body: Actually, I have integrated Crowd's (users and groups) with Confluence and Jira but one of my important requirements was to use crowd as SSO center and my web application should redirect to confluence/jira pages without login ???


Tags: confluence

jira