简体   繁体   English

如何在 React.js App 中集成 power-bi 行级安全?

[英]How to integrate power-bi Row Level Security in React.js App?

I have integrated power-bi service(App Owns Data/service principle way) in my react.js App.我在我的 react.js 应用程序中集成了 power-bi 服务(应用程序拥有数据/服务原则方式)。 Further I want to integrate RLS(Row Level Security) in the same.此外,我想将 RLS(行级安全性)集成到其中。 As mentioned in power-bi docs it is required to add c# code for embed token to generate and authenticate row level security.如 power-bi 文档中所述,需要为嵌入令牌添加 c# 代码以生成和验证行级安全性。

c# code: c# 代码:

public EmbedToken GetEmbedToken(Guid reportId, IList<Guid> datasetIds, [Optional] Guid targetWorkspaceId)
{
    PowerBIClient pbiClient = this.GetPowerBIClient();

   // Defines the user identity and roles.
    var rlsIdentity = new EffectiveIdentity(
        username: "France",
        roles: new List<string>{ "CountryDynamic" },
        datasets: new List<string>{ datasetId.ToString()}
    );
   
    // Create a request for getting an embed token for the rls identity defined above
    var tokenRequest = new GenerateTokenRequestV2(
        reports: new List<GenerateTokenRequestV2Report>() { new GenerateTokenRequestV2Report(reportId) },
        datasets: datasetIds.Select(datasetId => new GenerateTokenRequestV2Dataset(datasetId.ToString())).ToList(),
        targetWorkspaces: targetWorkspaceId != Guid.Empty ? new List<GenerateTokenRequestV2TargetWorkspace>() { new GenerateTokenRequestV2TargetWorkspace(targetWorkspaceId) } : null,
        identities: new List<EffectiveIdentity> { rlsIdentity }
    );

    // Generate an embed token
    var embedToken = pbiClient.EmbedToken.GenerateToken(tokenRequest);

    return embedToken;
}

I achieved this using express.js and react.js我使用 express.js 和 react.js 实现了这个

We need to get get Embed token using MSAL library(this can be done on server side only) and pass it on to client side using custom API call我们需要使用 MSAL 库获取嵌入令牌(这只能在服务器端完成)并使用自定义 API 调用将其传递到客户端

by using embed token,client Id and power-bi embed client API we can generate report on client side通过使用嵌入令牌、客户端 ID 和 power-bi 嵌入客户端 API 我们可以在客户端生成报告

RLS won't be applied for apps using a service principal. RLS 不会应用于使用服务主体的应用。

Reference: https://learn.microsoft.com/power-bi/enterprise/service-admin-rls#considerations-and-limitations参考: https://learn.microsoft.com/power-bi/enterprise/service-admin-rls#considerations-and-limitations

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM