Change comment:
Rewording, updated links
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki.S orin1 +XWiki.ManuelSmeria - Content
-
... ... @@ -186,10 +186,6 @@ 186 186 187 187 The specific packages to track for LDAP are ##com.xpn.xwiki.plugin.ldap## and ##com.xpn.xwiki.user.impl.LDAP##. 188 188 189 - 190 -Starting with XWiki 4.2 we added a new [[Logging UI>>extensions:Extension.Logging Application]] 191 - 192 - 193 193 In XWiki 3.4 you need to add the following in ##WEB-INF/classes/logback.xml##: 194 194 195 195 {{code}} ... ... @@ -391,54 +391,54 @@ 391 391 private static final Log LOG = LogFactory.getLog(SSOLdapAuthenicationImpl.class); 392 392 393 393 394 - 395 - 396 - 397 - 398 - 399 - 400 - 401 - 402 - 403 - 404 - 405 - 406 - 407 - 408 - 409 - 410 - 411 - 390 + public XWikiUser checkAuth(XWikiContext context) throws XWikiException { 391 + String user = getRemoteUser(context); 392 + if ((user != null) || !user.equals("")) { 393 + if (LOG.isInfoEnabled()) 394 + LOG.info("Launching create user for " + user); 395 + if ( authenticate(user, context) != null ) { 396 + if (LOG.isInfoEnabled()) 397 + LOG.info("Create user done for " + user); 398 + user = "XWiki." + user; 399 + context.setUser(user); 400 + System.out.println("User is set to:" + user); 401 + return new XWikiUser(user); 402 + } else { 403 + LOG.error( "User " + user + " can't be authenticated against ldap" ); 404 + } 405 + } 406 + return super.checkAuth(context); 407 + } 412 412 413 - 414 - 415 - 416 - 417 - 418 - 419 - 420 - 421 - 422 - 423 - 424 - 425 - 426 - 427 - 428 - 429 - 430 - 409 + /** 410 + * We cannot authenticate locally since we need to trust the app server for 411 + * authentication 412 + * 413 + * @param username 414 + * @param password 415 + * @param context 416 + * @return 417 + * @throws XWikiException 418 + */ 419 + public XWikiUser checkAuth(String username, String password, 420 + String rememberme, XWikiContext context) throws XWikiException { 421 + String user = getRemoteUser(context); 422 + if ((user == null) || user.equals("")) { 423 + return super.checkAuth(username, password, rememberme, context); 424 + } 425 + return checkAuth(context); 426 + } 431 431 432 - 433 - 434 - 435 - 436 - 437 - 438 - 439 - 440 - 441 - 428 + private String getRemoteUser(XWikiContext context) { 429 + String userName = context.getRequest().getHttpServletRequest() 430 + .getRemoteUser(); 431 + if (userName != null) { 432 + // only take the front of the username@domain 433 + String[] elements = userName.split("@", 2); 434 + userName = elements[0]; 435 + } 436 + return userName; 437 + } 442 442 443 443 public Principal authenticate(String login, XWikiContext context) throws XWikiException 444 444 {