Skip to content

Commit 1f0cc1c

Browse files
authored
Merge pull request #161 from britive/feature/v4.4.0
Feature/v4.4.0
2 parents d1604d4 + 1fa21f1 commit 1f0cc1c

15 files changed

Lines changed: 115 additions & 25 deletions

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Change Log (v2.8.1+)
22

3+
## v4.4.0 [2025-10-24]
4+
5+
__What's New:__
6+
7+
* Added Manager Approval support to `[application_management|secrets_manager|system]`.
8+
* Added GCP Federation Provider.
9+
10+
__Enhancements:__
11+
12+
* Added `manager_condition` parameter to `[application_management.profiles|secrets_manager|system].policies.build`.
13+
* Drop `socket` usage to speed up response times in specific scenarios, e.g., Windows DNS in WSL environments.
14+
15+
__Bug Fixes:__
16+
17+
* None
18+
19+
__Dependencies:__
20+
21+
* None
22+
23+
__Other:__
24+
25+
* Test naming convention updates.
26+
327
## v4.3.2 [2025-09-04]
428

529
__What's New:__

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ keywords = ["britive", "cpam", "identity", "jit"]
3333

3434
[project.optional-dependencies]
3535
azure = ["azure-identity"]
36+
gcp = ["google-auth"]
3637

3738
[project.urls]
3839
Homepage = "https://www.britive.com"

src/britive/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '4.3.2'
1+
__version__ = '4.4.0'

src/britive/application_management/applications.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ def scan(self, application_id: str, org_scan_only: bool = False) -> dict:
147147
:return: Details of the scan that was initiated.
148148
"""
149149

150-
return self.britive.application_management.scans.scan(application_id=application_id, org_scan_only=org_scan_only)
150+
return self.britive.application_management.scans.scan(
151+
application_id=application_id, org_scan_only=org_scan_only
152+
)
151153

152154
def delete(self, application_id: str) -> None:
153155
"""

src/britive/application_management/profiles/policies.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from typing import Union
2+
from typing import Literal, Union
33

44

55
class Policies:
@@ -25,6 +25,7 @@ def build( # noqa: PLR0913
2525
access_validity_time: int = 120,
2626
approver_users: list = None,
2727
approver_tags: list = None,
28+
manager_condition: Literal['All', 'Any', 'Manager'] = '',
2829
access_type: str = 'Allow',
2930
identifier_type: str = 'name',
3031
condition_as_dict: bool = False,
@@ -73,6 +74,10 @@ def build( # noqa: PLR0913
7374
If `approval_notification_medium` is set then either `approver_users` or `approver_tags` is required.
7475
:param approver_tags: Optional list of tag names who are considered approvers.
7576
If `approval_notification_medium` is set then either `approver_users` or `approver_tags` is required.
77+
:param manager_condition: Optional condition to enable requiring user's manager approval. Valid values are
78+
`Any` or `All` or `Manager`. `Any` corresponds to manager approval required, `All` corresponds to
79+
manager and approver_users/approver_tags approval required, and `Manager` corresponds to just the manager's
80+
approval required
7681
:param access_type: The type of access this policy provides. Valid values are `Allow` and `Deny`. Defaults
7782
to `Allow`.
7883
:param identifier_type: Valid values are `id` or `name`. Defaults to `name`. Represents which type of
@@ -105,6 +110,7 @@ def build( # noqa: PLR0913
105110
access_validity_time=access_validity_time,
106111
approver_users=approver_users,
107112
approver_tags=approver_tags,
113+
manager_condition=manager_condition,
108114
access_type=access_type,
109115
identifier_type=identifier_type,
110116
condition_as_dict=condition_as_dict,

src/britive/exceptions/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class MethodNotAllowed(BritiveException):
4949
class MissingAzureDependency(BritiveException):
5050
pass
5151

52+
class MissingGcpDependency(BritiveException):
53+
pass
5254

5355
class NoSecretsVaultFound(BritiveException):
5456
pass
@@ -57,6 +59,8 @@ class NoSecretsVaultFound(BritiveException):
5759
class NotExecutingInAzureEnvironment(BritiveException):
5860
pass
5961

62+
class NotExecutingInGcpEnvironment(BritiveException):
63+
pass
6064

6165
class NotExecutingInBitbucketEnvironment(BritiveException):
6266
pass

src/britive/federation_providers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .azure_user_assigned_managed_identity import AzureUserAssignedManagedIdentityFederationProvider
44
from .bitbucket import BitbucketFederationProvider
55
from .federation_provider import FederationProvider
6+
from .gcp import GcpFederationProvider
67
from .github import GithubFederationProvider
78
from .gitlab import GitlabFederationProvider
89
from .spacelift import SpaceliftFederationProvider
@@ -14,6 +15,7 @@ def __init__(self, britive) -> None:
1415
self.azure_system_assigned_managed_identity = AzureSystemAssignedManagedIdentityFederationProvider(britive)
1516
self.azure_user_assigned_managed_identity = AzureUserAssignedManagedIdentityFederationProvider(britive)
1617
self.bitbucket = BitbucketFederationProvider(britive)
18+
self.gcp = GcpFederationProvider(britive)
1719
self.generic = FederationProvider(britive)
1820
self.github = GithubFederationProvider(britive)
1921
self.gitlab = GitlabFederationProvider(britive)

src/britive/federation_providers/azure_system_assigned_managed_identity.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def get_token(self) -> str:
1717
return f'OIDC::{token}'
1818
except ImportError as e:
1919
raise MissingAzureDependency(
20-
'`azure-identity` package required to use the azure managed identity federation provider'
20+
'azure dependency package required to use the azure managed identity federation provider, '
21+
'install with `pip install britive[azure]'
2122
) from e
2223
except CredentialUnavailableError as e:
2324
msg = (

src/britive/federation_providers/azure_user_assigned_managed_identity.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def get_token(self) -> str:
1818
return f'OIDC::{token}'
1919
except ImportError as e:
2020
raise MissingAzureDependency(
21-
'`azure-identity` package required to use the azure managed identity federation provider'
21+
'azure dependency package required to use the azure managed identity federation provider, '
22+
'install with `pip install britive[azure]'
2223
) from e
2324
except CredentialUnavailableError as e:
2425
msg = (
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from britive.exceptions import MissingGcpDependency, NotExecutingInGcpEnvironment
2+
3+
from .federation_provider import FederationProvider
4+
5+
6+
class GcpFederationProvider(FederationProvider):
7+
def __init__(self, audience: str = None) -> None:
8+
self.audience = audience if audience else 'https://accounts.google.com/'
9+
super().__init__()
10+
11+
def get_token(self):
12+
try:
13+
from google.auth.exceptions import DefaultCredentialsError
14+
from google.auth.transport.requests import Request
15+
from google.oauth2 import id_token
16+
17+
token = id_token.fetch_id_token(Request(), self.audience)
18+
19+
return f'OIDC::{token}'
20+
except ImportError as e:
21+
raise MissingGcpDependency(
22+
'google dependency package required to use the gcp managed identity federation provider, '
23+
'install with `pip install britive[gcp]'
24+
) from e
25+
except DefaultCredentialsError as e:
26+
msg = (
27+
'the codebase is not executing in an Gcp environment or some other issue is causing the '
28+
'managed identity credentials to be unavailable'
29+
)
30+
raise NotExecutingInGcpEnvironment(msg) from e

0 commit comments

Comments
 (0)