Skip to main content

llamazure.rbac : Azure roles, users, and assignments

The llamazure.rbac package provides a helpful interface to Azure RBAC.

Benefits:

  • a coherent view of roles and assignments
  • automatically handles internals of the Azure RBAC model. For example, deleting a role will first delete all role assignments
  • automatic retries and waits for the cloud to work

rbac

Usage

For roles definitions and role assignments, create RoleOps with an AzRest created by its from_credential method:

from azure.identity import DefaultAzureCredential

from llamazure.azrest.azrest import AzRest
from llamazure.rbac.roles import RoleOps

role_ops = RoleOps(AzRest.from_credential(DefaultAzureCredential()))

For users and groups, create a Users or a Groups with a MSGraph created by their from_credentials method:

from azure.identity import DefaultAzureCredential

from llamazure.msgraph.msgraph import Graph
from llamazure.rbac.resources import Groups, Users

users = Users(Graph.from_credential(DefaultAzureCredential()))
groups = Groups(Graph.from_credential(DefaultAzureCredential()))

Create a role

from llamazure.rbac.roles import *

role = role_ops.rds.put(
    RoleDefinition.Properties(
        roleName="llamazure-rbac-asn",
        description="test finding assignments",
        permissions=[Permission(actions=["Microsoft.Authorization/*/read"])],
    ),
    scope="/subscriptions/00000000-0000-0000-0000-000000000000",
)

Assign a role

This will also automatically add the scope of assignment to the role's assignable scopes if necessary:

me = users.current()
role_ops.ras.assign(principalId=me["id"], principalType="User", role_name=role.properties.name,scope="/subscriptions/00000000-0000-0000-0000-000000000000")

Delete a role

This will also delete all role assignments before deleting a role:

role_ops.delete_role(role)

You can also delete a role by name:

role_ops.delete_by_name("llamazure-rbac-asn")

Get users with their groups

users.list_with_memberOf()

Get groups with their members

groups.list_with_memberships()

Metadata

Release files for llamazure.rbac 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llamazure.rbac 0.2.1
File Size Uploaded Provenance Actions
llamazure_rbac-0.2.1.tar.gz 11.9 kB Without provenance Details for llamazure_rbac-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llamazure.rbac 0.2.1
File Interpreter ABI Platform Actions
llamazure_rbac-0.2.1-py3-none-any.whl Python 3 none any Details for llamazure_rbac-0.2.1-py3-none-any.whl

Total release size: 25.6 kB

Release files / llamazure_rbac-0.2.1.tar.gz

Download URL llamazure_rbac-0.2.1.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
80b641d565d98b70f6c949edc3a8df18e0f85fed9ec5aae0951a8a11d242b8e6
BLAKE2b-256 checksum
How to use checksums
1f74bffab0234af1f65c82f0f3c85a4e6efab4f864d48859344569dadae75d37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / llamazure_rbac-0.2.1-py3-none-any.whl

Download URL llamazure_rbac-0.2.1-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4382d0fd98b7c274acfca1c39a49de04a56df4cca4b29aaa90556320582ea519
BLAKE2b-256 checksum
How to use checksums
048be6a73e783e16be137ecb6798062be23f152619805d8bb2ac0e49111c2218
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for llamazure.rbac 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page