Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-6254

Right after creating a new wiki using a template, owner's rights are not properly handled.

    XMLWordPrintable

Details

    • template rights owner
    • N/A
    • N/A

    Description

      How to reproduce:
      1. Run this from the main wiki using a "cleantemplate" wiki created with a default xe xar:

      {{velocity}}
      #set ($name = "testtt3")
      #set ($templateName = "cleantemplate")
      
      #set ($WikiManager = $xwiki.wikimanager)
      
      #set ($wikidocument = $WikiManager.createWikiDocument())
      #set ($wikidocumentobject = $wikidocument.createXObject("XWiki.XWikiServerClass"))
      
      
      Set:
      $wikidocument.set("owner", "xwiki:XWiki.Admin")
      $wikidocument.set("server", $name)
      $wikidocument.set("visibility", "Public")
      $wikidocument.set("state", "active")
      $wikidocument.set("homepage", "Main.WebHome")
      
      Get: 
      $wikidocument.owner
      $wikidocument.server
      $wikidocument.visibility
      $wikidocument.state
      $wikidocument.homepage
      
      Creating...
      #set ($result = $WikiManager.createNewWiki($name, $templateName, "", $wikidocument, true))
       Result: $result
      
      #set ($currentDatabase = $xcontext.database)
      #set ($ok = $xcontext.setDatabase($name))
       Changed DB.
      
       Testing "$wikidocument.wikiName:XWiki.XWikiPreferences" for admin
      $xwiki.hasAccessLevel("admin", "xwiki:$xcontext.user", "$wikidocument.wikiName:XWiki.XWikiPreferences") 
      edit
      $xwiki.hasAccessLevel("edit", "xwiki:$xcontext.user", "$wikidocument.wikiName:XWiki.XWikiPreferences") 
      view
      $xwiki.hasAccessLevel("view", "xwiki:$xcontext.user", "$wikidocument.wikiName:XWiki.XWikiPreferences") 
      rights to user "xwiki:$xcontext.user"
      
      Same, but for relative references: $xcontext.user - "XWiki.XWikiPreferences"
      $xwiki.hasAccessLevel("admin", $xcontext.user, "XWiki.XWikiPreferences") 
      $xwiki.hasAccessLevel("edit", $xcontext.user, "XWiki.XWikiPreferences") 
      $xwiki.hasAccessLevel("view", $xcontext.user, "XWiki.XWikiPreferences") 
      
      Same but with absolute user: "xwiki:$xcontext.user" - "XWiki.XWikiPreferences"
      $xwiki.hasAccessLevel("admin", "xwiki:$xcontext.user", "XWiki.XWikiPreferences") 
      $xwiki.hasAccessLevel("edit", "xwiki:$xcontext.user", "XWiki.XWikiPreferences") 
      $xwiki.hasAccessLevel("view", "xwiki:$xcontext.user", "XWiki.XWikiPreferences") 
      
      Restoring db.
      #set ($ok = $xcontext.setDatabase($currentDatabase))
      {{/velocity}}
      

      Output:

      Set:
      
      Get:
      xwiki:XWiki.Admin
      testtt3
      Public
      active
      Main.WebHome
      
      Creating...
      Result: -1
      
      Changed DB.
      
      Testing "testtt3:XWiki.XWikiPreferences" for admin
      true
      edit
      true
      view
      true
      rights to user "xwiki:XWiki.Admin"
      
      Same, but for relative references: XWiki.Admin - "XWiki.XWikiPreferences"
      false
      false
      false 
      
      Same but with absolute user: "xwiki:XWiki.Admin" - "XWiki.XWikiPreferences"
      true
      true
      true 
      
      Restoring db.
      

      Notice that the second attempt fails, reporting that the owner does not have rights.

      Attachments

        Issue Links

          Activity

            People

              softec Denis Gervalle
              enygma Eduard Moraru
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: