Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. ManuelSmeria1 +XWiki.Sorin - Content
-
... ... @@ -186,6 +186,10 @@ 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 + 189 189 In XWiki 3.4 you need to add the following in ##WEB-INF/classes/logback.xml##: 190 190 191 191 {{code}} ... ... @@ -387,54 +387,54 @@ 387 387 private static final Log LOG = LogFactory.getLog(SSOLdapAuthenicationImpl.class); 388 388 389 389 390 - 391 - 392 - 393 - 394 - 395 - 396 - 397 - 398 - 399 - 400 - 401 - 402 - 403 - 404 - 405 - 406 - 407 - 394 + public XWikiUser checkAuth(XWikiContext context) throws XWikiException { 395 + String user = getRemoteUser(context); 396 + if ((user != null) || !user.equals("")) { 397 + if (LOG.isInfoEnabled()) 398 + LOG.info("Launching create user for " + user); 399 + if ( authenticate(user, context) != null ) { 400 + if (LOG.isInfoEnabled()) 401 + LOG.info("Create user done for " + user); 402 + user = "XWiki." + user; 403 + context.setUser(user); 404 + System.out.println("User is set to:" + user); 405 + return new XWikiUser(user); 406 + } else { 407 + LOG.error( "User " + user + " can't be authenticated against ldap" ); 408 + } 409 + } 410 + return super.checkAuth(context); 411 + } 408 408 409 - 410 - 411 - 412 - 413 - 414 - 415 - 416 - 417 - 418 - 419 - 420 - 421 - 422 - 423 - 424 - 425 - 426 - 413 + /** 414 + * We cannot authenticate locally since we need to trust the app server for 415 + * authentication 416 + * 417 + * @param username 418 + * @param password 419 + * @param context 420 + * @return 421 + * @throws XWikiException 422 + */ 423 + public XWikiUser checkAuth(String username, String password, 424 + String rememberme, XWikiContext context) throws XWikiException { 425 + String user = getRemoteUser(context); 426 + if ((user == null) || user.equals("")) { 427 + return super.checkAuth(username, password, rememberme, context); 428 + } 429 + return checkAuth(context); 430 + } 427 427 428 - 429 - 430 - 431 - 432 - 433 - 434 - 435 - 436 - 437 - 432 + private String getRemoteUser(XWikiContext context) { 433 + String userName = context.getRequest().getHttpServletRequest() 434 + .getRemoteUser(); 435 + if (userName != null) { 436 + // only take the front of the username@domain 437 + String[] elements = userName.split("@", 2); 438 + userName = elements[0]; 439 + } 440 + return userName; 441 + } 438 438 439 439 public Principal authenticate(String login, XWikiContext context) throws XWikiException 440 440 {