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,8 @@ 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 +Starting with XWiki 4.2 we added a new [[Logging UI>>extensions:Extension.Logging Application]] from the Administration section, which allows logging to be enabled at runtime, directly from the UI, without the need to restart the wiki. 190 + 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 - 392 + public XWikiUser checkAuth(XWikiContext context) throws XWikiException { 393 + String user = getRemoteUser(context); 394 + if ((user != null) || !user.equals("")) { 395 + if (LOG.isInfoEnabled()) 396 + LOG.info("Launching create user for " + user); 397 + if ( authenticate(user, context) != null ) { 398 + if (LOG.isInfoEnabled()) 399 + LOG.info("Create user done for " + user); 400 + user = "XWiki." + user; 401 + context.setUser(user); 402 + System.out.println("User is set to:" + user); 403 + return new XWikiUser(user); 404 + } else { 405 + LOG.error( "User " + user + " can't be authenticated against ldap" ); 406 + } 407 + } 408 + return super.checkAuth(context); 409 + } 408 408 409 - 410 - 411 - 412 - 413 - 414 - 415 - 416 - 417 - 418 - 419 - 420 - 421 - 422 - 423 - 424 - 425 - 426 - 411 + /** 412 + * We cannot authenticate locally since we need to trust the app server for 413 + * authentication 414 + * 415 + * @param username 416 + * @param password 417 + * @param context 418 + * @return 419 + * @throws XWikiException 420 + */ 421 + public XWikiUser checkAuth(String username, String password, 422 + String rememberme, XWikiContext context) throws XWikiException { 423 + String user = getRemoteUser(context); 424 + if ((user == null) || user.equals("")) { 425 + return super.checkAuth(username, password, rememberme, context); 426 + } 427 + return checkAuth(context); 428 + } 427 427 428 - 429 - 430 - 431 - 432 - 433 - 434 - 435 - 436 - 437 - 430 + private String getRemoteUser(XWikiContext context) { 431 + String userName = context.getRequest().getHttpServletRequest() 432 + .getRemoteUser(); 433 + if (userName != null) { 434 + // only take the front of the username@domain 435 + String[] elements = userName.split("@", 2); 436 + userName = elements[0]; 437 + } 438 + return userName; 439 + } 438 438 439 439 public Principal authenticate(String login, XWikiContext context) throws XWikiException 440 440 {