Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d7db7c0
added support for self service profiles
Feb 23, 2025
4ab6647
added tests
Feb 23, 2025
40a6b90
fixed sphinx error, undid changes to pyproject.toml
Feb 23, 2025
2ab199d
undid changes to pyproject.toml
Feb 23, 2025
decbd5a
Bump actions/upload-pages-artifact from 2 to 3 (#581)
dependabot[bot] Jan 27, 2025
67be3f5
Bump actions/deploy-pages from 3 to 4 (#582)
dependabot[bot] Jan 27, 2025
c823bf4
Fixing the Github Workflow Issues (#644)
kishore7snehil Jan 27, 2025
17b311a
Adding Support For Back Channel Login (#643)
kishore7snehil Jan 28, 2025
95dda0b
Updating Dependancies And Workflow Action Versions (#653)
kishore7snehil Jan 28, 2025
013992e
Adding Support For RAR and JAR Requests (#659)
kishore7snehil Jan 29, 2025
3b3ddcf
Consolidated Community PRs and Dependency Upgrades (#660)
kishore7snehil Jan 29, 2025
863434f
Release 4.8.0 (#661)
kishore7snehil Jan 29, 2025
b60dbcd
fix: RL Scanner (#662)
kishore7snehil Jan 29, 2025
7163c6d
Adding Version To RL Scanner (#668)
kishore7snehil Jan 30, 2025
b78332a
Adding Support For Federated Login
kishore7snehil Jan 31, 2025
564700c
Changing the function name and typo correction
kishore7snehil Feb 4, 2025
5a465a6
Removing some attributes
kishore7snehil Feb 10, 2025
a5e07f5
Fix: Unauthorized Access Error For PAR
kishore7snehil Feb 11, 2025
a030c1c
Making the logic unit test compatible
kishore7snehil Feb 12, 2025
291d34c
fix:Change the federated connection function name (#674)
kishore7snehil Feb 24, 2025
4606675
revert: Reverting Access Token For Conn Changes (#675)
kishore7snehil Feb 24, 2025
c65a160
Release 4.8.1 (#676)
kishore7snehil Feb 24, 2025
2cd09b9
changed list function name to all
Feb 26, 2025
09f4123
fix: update snyk scan to utilize newest methodology
dennishenry Mar 20, 2025
49859b8
Adding Support For CIBA with RAR (#679)
kishore7snehil Mar 21, 2025
9cf504e
feat: Federated Connections Support
kishore7snehil Mar 29, 2025
1ac18d6
Release 4.9.0 (#683)
kishore7snehil Apr 1, 2025
bb956d2
Merge branch 'master' into add-self-service-profiles-api
kishore7snehil Jun 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ For more code samples on how to integrate the auth0-python SDK in your Python ap
- Roles() ( `Auth0().roles` )
- RulesConfigs() ( `Auth0().rules_configs` )
- Rules() ( `Auth0().rules` )
- SelfServiceProfiles() ( `Auth0().self_service_profiles` )
- Stats() ( `Auth0().stats` )
- Tenants() ( `Auth0().tenants` )
- Tickets() ( `Auth0().tickets` )
Expand Down
2 changes: 2 additions & 0 deletions auth0/management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .roles import Roles
from .rules import Rules
from .rules_configs import RulesConfigs
from .self_service_profiles import SelfServiceProfiles
from .stats import Stats
from .tenants import Tenants
from .tickets import Tickets
Expand Down Expand Up @@ -59,6 +60,7 @@
"Roles",
"RulesConfigs",
"Rules",
"SelfServiceProfiles",
"Stats",
"Tenants",
"Tickets",
Expand Down
4 changes: 4 additions & 0 deletions auth0/management/auth0.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .roles import Roles
from .rules import Rules
from .rules_configs import RulesConfigs
from .self_service_profiles import SelfServiceProfiles
from .stats import Stats
from .tenants import Tenants
from .tickets import Tickets
Expand Down Expand Up @@ -86,6 +87,9 @@ def __init__(
self.roles = Roles(domain, token, rest_options=rest_options)
self.rules_configs = RulesConfigs(domain, token, rest_options=rest_options)
self.rules = Rules(domain, token, rest_options=rest_options)
self.self_service_profiles = SelfServiceProfiles(
domain, token, rest_options=rest_options
)
self.stats = Stats(domain, token, rest_options=rest_options)
self.tenants = Tenants(domain, token, rest_options=rest_options)
self.tickets = Tickets(domain, token, rest_options=rest_options)
Expand Down
180 changes: 180 additions & 0 deletions auth0/management/self_service_profiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
from __future__ import annotations

from typing import Any, List # List is being used as list is already a method.

from ..rest import RestClient, RestClientOptions
from ..types import TimeoutType


class SelfServiceProfiles:
"""Auth0 Self Service Profiles endpoints

Args:
domain (str): Your Auth0 domain, e.g: 'username.auth0.com'

token (str): Management API v2 Token

telemetry (bool, optional): Enable or disable Telemetry
(defaults to True)

timeout (float or tuple, optional): Change the requests
connect and read timeout. Pass a tuple to specify
both values separately or a float to set both to it.
(defaults to 5.0 for both)

protocol (str, optional): Protocol to use when making requests.
(defaults to "https")

rest_options (RestClientOptions): Pass an instance of
RestClientOptions to configure additional RestClient
options, such as rate-limit retries.
(defaults to None)
"""

def __init__(
self,
domain: str,
token: str,
telemetry: bool = True,
timeout: TimeoutType = 5.0,
protocol: str = "https",
rest_options: RestClientOptions | None = None,
) -> None:
self.domain = domain
self.protocol = protocol
self.client = RestClient(
jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options
)

def _url(self, profile_id: str | None = None) -> str:
url = f"{self.protocol}://{self.domain}/api/v2/self-service-profiles"
if profile_id is not None:
return f"{url}/{profile_id}"
return url

def all(
self,
page: int = 0,
per_page: int = 25,
include_totals: bool = True,
) -> List[dict[str, Any]]:
"""List self-service profiles.

Args:
page (int, optional): The result's page number (zero based). By default,
retrieves the first page of results.

per_page (int, optional): The amount of entries per page. By default,
retrieves 25 results per page.

include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise. Defaults to True.

See: https://auth0.com/docs/api/management/v2/self-service-profiles/get-self-service-profiles
"""

params = {
"page": page,
"per_page": per_page,
"include_totals": str(include_totals).lower(),
}

return self.client.get(self._url(), params=params)

def create(self, body: dict[str, Any]) -> dict[str, Any]:
"""Create a new self-service profile.

Args:
body (dict): Attributes for the new self-service profile.

See: https://auth0.com/docs/api/management/v2/self-service-profiles/post-self-service-profiles
"""

return self.client.post(self._url(), data=body)

def get(self, profile_id: str) -> dict[str, Any]:
"""Get a self-service profile.

Args:
id (str): The id of the self-service profile to retrieve.

See: https://auth0.com/docs/api/management/v2/self-service-profiles/get-self-service-profiles-by-id
"""

return self.client.get(self._url(profile_id))

def delete(self, profile_id: str) -> None:
"""Delete a self-service profile.

Args:
id (str): The id of the self-service profile to delete.

See: https://auth0.com/docs/api/management/v2/self-service-profiles/delete-self-service-profiles-by-id
"""

self.client.delete(self._url(profile_id))

def update(self, profile_id: str, body: dict[str, Any]) -> dict[str, Any]:
"""Update a self-service profile.

Args:
id (str): The id of the self-service profile to update.

body (dict): Attributes of the self-service profile to modify.

See: https://auth0.com/docs/api/management/v2/self-service-profiles/patch-self-service-profiles-by-id
"""

return self.client.patch(self._url(profile_id), data=body)

def get_custom_text(
self, profile_id: str, language: str, page: str
) -> dict[str, Any]:
"""Get the custom text for a self-service profile.

See: https://auth0.com/docs/api/management/v2/self-service-profiles/get-self-service-profile-custom-text
"""

url = self._url(f"{profile_id}/custom-text/{language}/{page}")
return self.client.get(url)

def update_custom_text(
self, profile_id: str, language: str, page: str, body: dict[str, Any]
) -> dict[str, Any]:
"""Update the custom text for a self-service profile.

See: https://auth0.com/docs/api/management/v2/self-service-profiles/put-self-service-profile-custom-text
"""

url = self._url(f"{profile_id}/custom-text/{language}/{page}")
return self.client.put(url, data=body)

def create_sso_ticket(
self, profile_id: str, body: dict[str, Any]
) -> dict[str, Any]:
"""Create a single sign-on ticket for a self-service profile.

Args:
id (str): The id of the self-service profile to create the ticket for.

body (dict): Attributes for the single sign-on ticket.

See: https://auth0.com/docs/api/management/v2/self-service-profiles/post-sso-ticket
"""

url = self._url(f"{profile_id}/sso-ticket")
return self.client.post(url, data=body)

def revoke_sso_ticket(self, profile_id: str, ticket_id: str) -> None:
"""Revoke a single sign-on ticket for a self-service profile.

Args:
id (str): The id of the self-service profile to revoke the ticket from.

ticket (str): The ticket to revoke.

See: https://auth0.com/docs/api/management/v2/self-service-profiles/post-revoke
"""

url = self._url(f"{profile_id}/sso-ticket/{ticket_id}/revoke")
self.client.post(url)
124 changes: 124 additions & 0 deletions auth0/test/management/test_self_service_profiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import unittest
from unittest import mock

from ...management.self_service_profiles import SelfServiceProfiles


class TestSelfServiceProfiles(unittest.TestCase):
def test_init_with_optionals(self):
t = SelfServiceProfiles(
domain="domain", token="jwttoken", telemetry=False, timeout=(10, 2)
)
self.assertEqual(t.client.options.timeout, (10, 2))
telemetry_header = t.client.base_headers.get("Auth0-Client", None)
self.assertEqual(telemetry_header, None)

@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_all(self, mock_rc):
mock_instance = mock_rc.return_value

s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.all()

mock_instance.get.assert_called_with(
"https://domain/api/v2/self-service-profiles",
params={"page": 0, "per_page": 25, "include_totals": "true"},
)

s.all(page=1, per_page=50, include_totals=False)

mock_instance.get.assert_called_with(
"https://domain/api/v2/self-service-profiles",
params={"page": 1, "per_page": 50, "include_totals": "false"},
)

@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_create(self, mock_rc):
mock_instance = mock_rc.return_value

s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.create({"name": "test"})

mock_instance.post.assert_called_with(
"https://domain/api/v2/self-service-profiles", data={"name": "test"}
)

@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_get(self, mock_rc):
mock_instance = mock_rc.return_value

s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.get("an-id")

mock_instance.get.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id"
)

@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_delete(self, mock_rc):
mock_instance = mock_rc.return_value

s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.delete("an-id")

mock_instance.delete.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id"
)

@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_update(self, mock_rc):
mock_instance = mock_rc.return_value

s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.update("an-id", {"a": "b", "c": "d"})

mock_instance.patch.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id",
data={"a": "b", "c": "d"},
)

@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_get_custom_text(self, mock_rc):
mock_instance = mock_rc.return_value

s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.get_custom_text("an-id", "en", "page")

mock_instance.get.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id/custom-text/en/page"
)

@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_update_custom_text(self, mock_rc):
mock_instance = mock_rc.return_value

s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.update_custom_text("an-id", "en", "page", {"a": "b", "c": "d"})

mock_instance.put.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id/custom-text/en/page",
data={"a": "b", "c": "d"},
)

@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_create_sso_ticket(self, mock_rc):
mock_instance = mock_rc.return_value

s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.create_sso_ticket("an-id", {"a": "b", "c": "d"})

mock_instance.post.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id/sso-ticket",
data={"a": "b", "c": "d"},
)

@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_revoke_sso_ticket(self, mock_rc):
mock_instance = mock_rc.return_value

s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.revoke_sso_ticket("an-id", "ticket-id")

mock_instance.post.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id/sso-ticket/ticket-id/revoke"
)
8 changes: 8 additions & 0 deletions docs/source/management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ management.rules module
:undoc-members:
:show-inheritance:

management.self_service_profiles module
-----------------------------------------

.. automodule:: auth0.management.self_service_profiles
:members:
:undoc-members:
:show-inheritance:

management.stats module
--------------------------

Expand Down
Loading