$ show microsoft/PowerBI-Developer-Samples
This repository is a collection of sample applications and scripts demonstrating how to embed Power BI reports, dashboards, and tiles into custom applications. It covers two primary embedding scenarios: 'App Owns Data' (service principal or master user authentication) and 'User Owns Data' (delegated user authentication). The samples are implemented in multiple languages and frameworks, including ASP.NET Core, ASP.NET Framework, Python Flask, Node.js Express, Java Spring MVC, and React-TS, providing a consistent pattern across stacks. Additionally, the repo includes credential encryption samples for Power BI on-premises gateway data sources, implementing asymmetric key encryption (RSA-OAEP with AES-256-CBC and HMAC-SHA256), and a set of PowerShell scripts for administrative tasks such as workspace management, deployment pipelines, and dataset refresh. The code is explicitly educational and not production-ready. It focuses on demonstrating the integration flow with the Power BI REST API and Azure AD authentication. While the samples are functional, they suffer from significant duplication across languages, with nearly identical logic reimplemented in each stack. Many dependencies are outdated (e.g., cryptography 3.4.6, Flask 2.1.2, msal 1.9.0, React 16), and the code lacks automated tests. The encryption helpers, however, are well-structured and isolated, making them potentially reusable in other projects that need to encrypt credentials for Power BI gateways. Overall, the repository serves as a practical reference for developers learning Power BI embedding, but it requires careful updating and hardening for production use.
The LLM identified 5 files worth highlighting for reuse:
Implements asymmetric key encryption for 1024-bit RSA keys using RSA-OAEP to wrap an AES-256 session key, which is used to encrypt the payload via AES-256-CBC with HMAC-SHA256 authentication. This helper is self-contained, has no internal dependencies outside the JDK crypto libraries, and can be extracted and reused in any Java project that needs to encrypt credentials for Power BI on-premises gateways.
Similar to Asymmetric1024KeyEncryptionHelper but supports RSA keys with modulus sizes larger than 1024 bits. It uses segment-based RSA-OAEP encryption for the session key due to key size limitations. The implementation is isolated and follows the same cryptographic pattern, making it reusable for encrypting credentials with higher security keys.
Provides AES-256-CBC encryption with HMAC-SHA256 authentication. It is used by the asymmetric key encryption helpers to encrypt the actual credential payload. The class is self-contained and can be reused independently for any symmetric encryption task requiring authenticated encryption.
Python port of the asymmetric key encryption helper for higher modulus keys. Uses the cryptography library to implement RSA-OAEP wrapping and AES-256-CBC with HMAC-SHA256. It is a clean, self-contained module that can be extracted and reused in Python projects for Power BI gateway credential encryption.
Python implementation of AES-256-CBC authenticated encryption with HMAC-SHA256. It is a standalone helper that can be reused for any symmetric encryption workflow requiring confidentiality and integrity.