MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Dataverse-Python-Authentication-Security

Dataverse-Python-Authentication-Security是一款code方向的AI技能,核心价值是# Dataverse SDK for Python — Authentication & Security Patterns Based on official Microsoft Azure SDK authentication documentation and Dataverse SDK best practices,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

# Dataverse SDK for Python — Authentication & Security Patterns Based on official Microsoft Azure SDK authentication documentation and Dataverse SDK best practices. ## 1. Authentication Overview Th

Last verified on: 2026-05-30
mkdir -p ./skills/dataverse-python-authentication-security && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/dataverse-python-authentication-security/SKILL.md -o ./skills/dataverse-python-authentication-security/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# Dataverse SDK for Python — Authentication & Security Patterns


Based on official Microsoft Azure SDK authentication documentation and Dataverse SDK best practices.


1. Authentication Overview


The Dataverse SDK for Python uses Azure Identity credentials for token-based authentication. This approach follows the principle of least privilege and works across local development, cloud deployment, and on-premises environments.


Why Token-Based Authentication?


**Advantages over connection strings**:

- Establishes specific permissions needed by your app (principle of least privilege)

- Credentials are scoped only to intended apps

- With managed identity, no secrets to store or compromise

- Works seamlessly across environments without code changes


---


2. Credential Types & Selection


Interactive Browser Credential (Local Development)


**Use for**: Developer workstations during local development.


python
from azure.identity import InteractiveBrowserCredential
from PowerPlatform.Dataverse.client import DataverseClient

# Opens browser for authentication
credential = InteractiveBrowserCredential()
client = DataverseClient(
    base_url="https://myorg.crm.dynamics.com",
    credential=credential
)

# First use prompts for sign-in; subsequent calls use cached token
records = client.get("account")

**When to use**:

- ✅ Interactive development and testing

- ✅ Desktop applications with UI

- ❌ Background services or scheduled jobs


---


Default Azure Credential (Recommended for All Environments)


**Use for**: Apps that run in multiple environments (dev → test → production).


python
from azure.identity import DefaultAzureCredential
from PowerPlatform.Dataverse.client import DataverseClient

# Attempts credentials in this order:
# 1. Environment variables (app service principal)
# 2. Azure CLI credentials (local development)
# 3. Azure PowerShell credentials (local development)
# 4. Managed identity (when running in Azure)
credential = DefaultAzureCredential()

client = DataverseClient(
    base_url="https://myorg.crm.dynamics.com",
    credential=credential
)

records = client.get("account")

**Advantages**:

- Single code path works everywhere

- No environment-specific logic needed

- Automatically detects available credentials

- Preferred for production apps


**Credential chain**:

1. Environment variables (`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`)

2. Visual Studio Code login

3. Azure CLI (`az login`)

4. Azure PowerShell (`Connect-AzAccount`)

5. Managed identity (on Azure VMs, App Service, AKS, etc.)


---


Client Secret Credential (Service Principal)


**Use for**: Unattended authentication (scheduled jobs, scripts, on-premises services).


python
from azure.identity import ClientSecretCredential
from PowerPlatform.Dataverse.client import DataverseClient
import os

credential = ClientSecretCredential(
    tenant_id=os.environ["AZURE_TENANT_ID"],
    client_id=os.environ["AZURE_CLIENT_ID"],
    client_secret=os.environ["AZURE_CLIENT_SECRET"]
)

client = DataverseClient(
    base_url="https://myorg.crm.dynamics.com",
    credential=credential
)

records = client.get("account")

**Setup steps**:

1. Create app registration in Azure AD

2. Create client secret (keep secure!)

3. Grant Dataverse permissions to the app

4. Store credentials in environment variables or secure vault


**Security concerns**:

- ⚠️ Never hardcode credentials in source code

- ⚠️ Store secrets in Azure Key Vault or environment variables

- ⚠️ Rotate credentials regularly

- ⚠️ Use minimal required permissions


---


Managed Identity Credential (Azure Resources)


**Use for**: Apps hosted in Azure (App Service, Azure Functions, AKS, VMs).


python
from azure.identity import ManagedIdentityCredential
from PowerPlatform.Dataverse.client import DataverseClient

# No secrets needed - Azure manages identity
credential = ManagedIdentityCredential()

client = DataverseClient(
    base_url="https://myorg.crm.dynamics.com",

🎯 Best For

  • Security auditors
  • DevSecOps teams
  • Compliance officers
  • Technical writers
  • API documentation teams

💡 Use Cases

  • Auditing dependencies for known CVEs
  • Scanning API endpoints for auth gaps
  • Generating JSDoc/TSDoc comments
  • Writing README files for new projects

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Dataverse-Python-Authentication-Security to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Can this replace a dedicated SAST tool?

AI-based security review is complementary to SAST tools. Use it as a first-pass filter, not a replacement.

Does it follow my documentation style?

Most documentation skills respect existing style. Provide a style guide or example in your prompt.

Is Dataverse-Python-Authentication-Security compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Dataverse-Python-Authentication-Security?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Dataverse-Python-Authentication-Security?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/dataverse-python-authentication-security/SKILL.md, ready to use.

⚠️ Common Mistakes to Avoid

Only scanning surface-level issues

Deep security review requires understanding your app architecture, not just regex patterns.

Auto-generating without reviewing

AI documentation can contain inaccuracies. Always verify technical accuracy.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills