Re: [xwiki-devs] CAS Integration + new User creation
Hi All, I finally got it. I was trying to create a user without the "XWiki." prefix but when I discovered that if I creates it using the createUser method from the XWiki class, the username must NOT have that prefix, but the new XWikiUser that checkAuth returns must have it. I followed the XWikiSunSSOAuthenticator code and found the solution. Again, many thanks you for your help Marco A. Gonzalez Date: Fri, 25 Mar 2011 12:46:27 +0100 From: Thomas Mortagne <thomas.mortagne@xwiki.com> Subject: Re: [xwiki-devs] CAS Integration + new User creation To: XWiki Developers <devs@xwiki.org> Message-ID: <AANLkTimN8OT5Nr+=5dLJ6WdQ-M3V9tpwGr3KFk9zeB0E@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 On Fri, Mar 25, 2011 at 12:46, Thomas Mortagne <thomas.mortagne@xwiki.com> wrote:
Hi,
As Kevin suggested it's a good idea to follow existing authenticators on http://svn.xwiki.org/svnroot/xwiki/contrib/sandbox/authenticators/
Note that you get reuse some generic abstract classes in http://svn.xwiki.org/svnroot/xwiki/contrib/sandbox/authenticators/xwiki-auth... to make it easier for you?
Remove the "?" here :)
2011/3/25 Marco Antonio Gonz?lez <magonzalez@grupointermark.com>:
Hi,
Are you sure wikiname (not a very good variable name ;) ) includes the "XWiki." prefix?
When I try to use createEmptyUser(xwikiname, userRights, context) from an XWiki object (context.getWiki()) if I manually add "XWiki." in the "xwikiname" it creates an "XWiki.mynewuser", but on the Admin Users page it doesn't looks like a normal user, it lacks many of the the user properties and doesn't have the XWiki.XWikiUserSheet in it's content, also when I try to get it's XWikiDocument it appears as XWiki.XWiki.mynewuser.
I'm working with XWiki version 2.4 (xwiki-core-2.4.jar
Currently, I'm checking how XWikiSunSSOAuthenticator does it, checking what I do wrong.
Thank you, Marco A. Gonzalez
Date: Fri, 25 Mar 2011 11:44:30 +0200 From: Marius Dumitru Florea <mariusdumitru.florea@xwiki.com> Subject: Re: [xwiki-devs] CAS Integration + new User creation
Hi Marco,
On 03/25/2011 10:40 AM, Marco Antonio Gonz?lez wrote:
Hi all,
I'm new developing with XWiki, and I'm not sure this list is the correct to post this, so sorry in advance for any inconvenience and my bad english.
I'm trying to get an integration with CAS Auth instead of own XWiki Auth, but when I try to create a user on my own implementation of XWikiAuthServiceImpl, the user is created on XWiki space, but when i log into XWiki and Main is my default Space, the Profile link on top points to /xwiki/bin/view/Main/mynewuser instead of /xwiki/bin/view/XWiki/mynewuser where I can edit his first name, surname, etc. Is this the default behaviour? If not, any suggestions of what I do wrong?
The autentication code is, in my CASAuthServiceImpl class:
public XWikiUser checkAuth(XWikiContext context) throws XWikiException { ? ? String remoteUser = context.getRequest().getRemoteUser(); ? ? String wikiname = ""; ? ? if ((remoteUser == null) || remoteUser.equals("")) { ? ? ? ?getLogger().warn("checkAuth: User cannot be authenticated (REMOTE_USER is null)"); ? ? ? ?try { ? ? ? ? ? context.getResponse().sendRedirect("/cas/login"); ? ? ? ?} catch (IOException ioe) { ? ? ? ? ? getLogger().warn("checkAuth: CAS Error. Let XWiki handle it. "); ? ? ? ? ? return super.checkAuth(context); ? ? ? ?} ? ? } else if (remoteUser.equalsIgnoreCase("xwiki")) { ? ? ? ?getLogger().warn("checkAuth: User is XWIKI (superadmin)"); ? ? ? ?wikiname = "XWiki.superadmin"; ? ? } else { ? ? ? ?XWiki wiki = context.getWiki();
? ? ? ?wikiname = wiki.clearName(remoteUser, true, true, context);
Are you sure wikiname (not a very good variable name ;) ) includes the "XWiki." prefix?
? ? ? ?this.context.getWiki().createEmptyUser(wikiname, "edit", context); ? ? }
? ? context.setUser(wikiname);
References are resolved relative to the current context:
Foo ? ? ? ? ?-> currentWiki:currentSpace.Foo Bar.Foo ? ? ?-> currentWiki:Bar.Foo wiki:Bar.Foo -> wiki:Bar.Foo
Hope this helps, Marius
? ? return new XWikiUser(wikiname); } catch (XWikiException e) { ? ? getLogger().error("checkAuth: Cannot validate user. " + e.getMessage()); ? ? throw e; }
Thank you, Marco A. Gonzalez _______________________________________________ devs mailing list devs@xwiki.org http://lists.xwiki.org/mailman/listinfo/devs
devs mailing list devs@xwiki.org http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne
participants (1)
-
Marco Antonio González