Jump to content
We've recently updated our Privacy Statement, available here ×

Domain Security using tenantId


pw1971
Go to solution Solved by andrewsok,

Recommended Posts

We're looking to use V3.5 and the new mulit-tenancy features.  Reviewing the supermartDomain_security example it demonstrates looking up a tenantId from the user table and applying this as a filter, extract is shown below:

------------------------------------

<!-- For multi-tenancy demo.
    Assumes state abbreviations are used for the Organization ID (tenantId).
    Examples:
      Organization Names : California, Washington, Oregon
      Organization IDs (tenantId) : ca, wa, or  (tenantId maps to the values held in store_state)
    -->

    <!-- for Sales -->
    <!--resourceAccessGrant id="sales_join_ROLE_SUPERMART_TENANTID_row_grant">
     <principalExpression>authentication.principal.tenantId != null</principalExpression>
            <filterExpression>store1.store_state in (groovy('authentication.principal.tenantId.toUpperCase()'))</filterExpression>
        </resourceAccessGrant-->

      </resourceAccessGrants>
    </resourceAccessGrantList>

------------------------------------

I have tried to change this for our requirements as shown below but receive "An error has occured uploading the security file"  when trying to upload it using the Domain/Add Security option.

<securityDefinition xmlns="http://www.jaspersoft.com/2007/SL/XMLSchema" version="1.0" itemGroupDefaultAccess="granted">

    <resourceAccessGrants>
   
    <resourceAccessGrant id="JoinTree_1">
     <principalExpression>authentication.getPrincipal().tenantId != null</principalExpression>
            <filterExpression>TableName.OwnerID in (groovy('authentication.principal.tenantId.toUpperCase()'))</filterExpression>
   
    </resourceAccessGrant-->

    </resourceAccessGrants>

</securityDefinition>

 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

 I am not sure whether you posted a full version of your security file, or just part of it, but it is incorrect from XML and XSD point of view (which very likely is what is causing the error).

Here is the valid version, please, try it.

Code:
<securityDefinition xmlns="http://www.jaspersoft.com/2007/SL/XMLSchema" version="1.0" itemGroupDefaultAccess="granted">  <resourceAccessGrants>    <resourceAccessGrantList id="JoinTree_1_grantList" label="aLabel" resourceId="JoinTree_1">      <resourceAccessGrants>        <resourceAccessGrant id="JoinTree_1_grant">          <principalExpression>authentication.getPrincipal().tenantId != null</principalExpression>          <filterExpression>TableName.OwnerID in (groovy('authentication.principal.tenantId.toUpperCase()'))</filterExpression>        </resourceAccessGrant>      </resourceAccessGrants>    </resourceAccessGrantList>  </resourceAccessGrants></securityDefinition>
Link to comment
Share on other sites

It works but I am struggling to get the tenanId, I have tried <filterExpression>OwnerID in (groovy('authentication.principal.tenantId'))</filterExpression> but it doesn't allow any data to be retrieved.

It works if I manually set it as <filterExpression>OwnerID in ('2')</filterExpression>

Thanks.

Link to comment
Share on other sites

What's the correct syntax for this as the below errors:

 

OwnerID in (groovy((com.jaspersoft.jasperserver.multipleTenancy.MTWebAuthenticationDetails)(org.acegisecurity.context.SecurityContextHolder.getContext().getAuthentication().getDetails())).getTenantId()

 

Link to comment
Share on other sites

The following syntax works:

<filterExpression>OwnerName in (groovy('authentication.getPrincipal().getTenantId()'))</filterExpression>

Note that the getTenantId() returns the value stored in the tenantId field in the jasperserver.JITenant table.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...