Jump to content
We've recently updated our Privacy Statement, available here ×
  • Assigning roles to users within an Organization with REST v2


    stasp
    • Features: Web Services Version: v6.3, v5.6.1 Product: JasperReports® Server

    Issue Description

    User request:


    We would like to use the REST V2 API to add users to ROLES. We built a PERL script so we could automate it. The problem is that when we run the REST V2 API, it only works for ROLES created outside the organization. 
     
    For example, let's say we have an organization - Org_A. A ROLE_ALL_REPORTS role was created for this organization. We need to add the users from Org_A to the ROLE_ALL_REPORTS also from Org_A. The Web Services guide says that in order to assign role membership to a user, we need to set the roles property on the user account with the PUT method of the REST V2 users service. 
     
    We are using the PUT method and the URL (http://<host>:<port>/jasperserver[-pro]/rest_v2/organizations/orgID/users/userID) to specify the user’s organization. We log in as the system admin - superuser. 
     
    If we do not create the ROLE_ALL_REPORTS role outside the Org_A, we get bad request as the response. If we create the ROLE_ALL_REPORTS outside the organization, the request is ok however this is not the result we expect because we are going to have several tenants (organizations), each one having its users and roles. 
     
    You can try to reproduce using the RESTClient add-on and Firefox. 
     
    1) Create an organization (Org_A) 
    2) Create a user in the organization (reportdev) 
    3) Create a ROLE for this organization, such as ROLE_ALL_REPORTS 
    4) Using basic authentication (superuser/superuser) and content type as application/JSON, send the following PUT request: 
     
    http request: http://<JasperReports server>/jasperserver-pro/rest_v2/organizations/Org_A/users/reportdev 
     
    body: 

     

    { 
        "roles":[{"name":"ROLE_USER"},{"name":"ROLE_ALL_REPORTS"}] 
    } 
     
    We were expecting that since we are using the URL that specifies the organization, and the API takes into consideration the user’s organization, it should also take into consideration the user’s organization for the ROLES we are providing as part of the request. It should all be in the same context.

     

     

    Resolution

    Specify the tenant ID for the role in the body of request as follows: 
    { 
        "roles": 
            [{"name":"ROLE_USER"}, 
             {"name":"ROLE_ALL_REPORTS", "tenantId":"Org_A"}] 
    }
    

    Note for TIBCO JasperReports Server® v6.3.0

    In this version there appeats to be no need to explicitely specify tenantId any more.

    The test on this version was performed using the Advanced Rest Client plugin for Chrome browser


    Ref. Case 00059249

     


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...