britive


Namebritive JSON
Version 3.1.0 PyPI version JSON
download
home_pageNone
SummaryA pure Python SDK for the Britive API
upload_time2024-10-08 00:58:45
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2022 Britive, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords britive cpam identity jit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Britive Python SDK

Pure Python implementation for interacting with the [Britive API](https://docs.britive.com/v1/docs/en/overview-britive-apis).

This package aims to wrap the Britive API for usage in Python development. For the most part it is a simple wrapper
(sending potentially bad parameters to the API) but there are a couple of places where liberties were taken to enhance
the developer/end user experience. Some APIs may also be combined into one Python method with a parameter if and where
it makes more sense to present the API that way.

This package supports Python versions `>= 3.8`.

## Installation

```sh
pip install britive
```

Or execute one of the following commands if you wish to pull directly from the Github repo instead of PyPi. Or navigate
to Releases and use the URL of the tarball release that is needed, if not the lastest.

```sh
pip install $(curl -s https://api.github.com/repos/britive/python-sdk/releases/latest \
    | jq -r '.assets[] | select(.content_type == "application/x-gzip") | .browser_download_url')

OR

pip install $(curl -s https://api.github.com/repos/britive/python-sdk/releases/latest \
    | grep "browser_download_url.*.tar.gz" | cut -d : -f 2,3 | tr -d \")
```

## Documentation

Each public method is documented with a docstring which provides details on what the method does, the parameters the
method accepts, and details about what is returned from the method.

Official API documentation can be found here: [Overview of Britive APIs](https://docs.britive.com/v1/docs/en/overview-britive-apis).

## Authentication

Authentication is handled solely via API tokens. The token must be provided in one of two methods.

1. Passed directly into the class constructor.
2. Injected as an environment variable into the execution context where this package is being run.
    1. The environment variable name must be `BRITIVE_API_TOKEN`.

> _As of `v2.5.0` a `Bearer` token can be provided as well._
> _A `Bearer` token is generated as part of an interactive login process and is temporary in nature._
> _This is to support the [Britive Python CLI](https://github.com/britive/python-cli/)._

All Britive API tokens are authenticated against a specific Britive tenant. The name of the tenant must be presented in
one of two methods.

1. Passed directly into the `Britive` class constructor.
2. Injected as an environment variable into the execution context where this package is being run.
    1. The environment variable name must be `BRITIVE_TENANT`.

> _In order to obtain the tenant name, reference the Britive URL used to log into the UI._
> _If the URL is `https://example.britive-app.com` then the tenant name will be `example`._

## Pagination

All pagination is handled by the package. The caller will never have to deal with paginated responses.

## Assumptions

* The caller has access to an active Britive tenant.
* The caller has been granted an API token and/or has the ability to generate an API token.
  * This can be either for a _User_ or _Service Identity_.
* No assumptions are made about the operating system or file system.
  * Nothing is persisted to disk.
    * The end user must persist responses to disk if and when that is required.

## Resource Coverage

The following Britive resources are supported with full CRUDL operations where appropriate, and additional actions where
they exist.

* Access Broker
* Access Builder
* Accounts
* Accounts (associated with an application/environment)
* API Tokens (for Users)
* Applications
* Audit Logs
* Environment
* Environment Groups
* Groups (associated with an application/environment)
* Identity Attributes
* Identity Providers
* My Access (access granted to the given identity (user or service))
* My Resources (access granted to the given identity (user or service))
* My Secrets (access granted to the given identity (user or service))
* Notifications
* Permissions (associated with an application/environment)
* Profiles
* Reports
* SAML Settings
* Scans
* Security Policies
* Service Identities
* Service Identity Tokens
* System Announcement (aka banner)
* Tags (aka User Tags)
* Task Services
* Tasks
* Users

## Proxies

Under the covers, python [`requests`](https://github.com/psf/requests) is being used to communicate with the Britive API.
As such, any functionality of `requests` can be used, including setting an HTTP proxy.

* HTTP proxies will be set via environment variables.
  * `HTTP_PROXY`
  * `HTTPS_PROXY`
  * `NO_PROXY`
  * `http_proxy`
  * `https_proxy`
  * `no_proxy`

> _Standard HTTP proxy URLs should be utilized._
>
> _Examples:_
>
> * _Unauthenticated Proxy: `http://internalproxy.domain.com:8080`_
> * _Authenticated Proxy: `http://user:pass@internalproxy.domain.com:8080`_

## Custom TLS Certificates

Setting custom TLS certificates functionality of `requests` can also be used.

* Certificate bundles can be set via environment variables.
  * `REQUESTS_CA_BUNDLE`
  * `CURL_CA_BUNDLE` _(used as a fallback)_
  * `PYBRITIVE_CA_BUNDLE` _(specific to the Britive Python SDK)_

> _The values of these environment variables must be a path to a directory of certificates or a specific certificate._
>
> _Example:_
> _`/path/to/certfile`_

### Platform Examples

#### linux/macos

```sh
export REQUESTS_CA_BUNDLE="/usr/local/corp-proxy/cacert.pem"
```

#### windows

__powershell:__

```pwsh
$env:REQUESTS_CA_BUNDLE = "C:\Users\User\AppData\Local\corp-proxy\cacert.pem"
```

__cmd:__

```bat
set REQUESTS_CA_BUNDLE="C:\Users\User\AppData\Local\corp-proxy\cacert.pem"
```

## Examples

### Importing

This should be the only class that is required for import.

```python
from britive.britive import Britive
```

Optionally, the various exceptions that this package raises can be imported as well, e.g.

```python
from britive import exceptions
```

Then specific exception(s) could be referenced as demonstrated below:

```python
try:
    something()
except exceptions.TokenMissingError():
    handle()
```

### List All Users

```python
from britive.britive import Britive
import json

britive = Britive()  # source needed data from environment variables

print(json.dumps(britive.users.list(), indent=2, default=str))
```

### Provide Needed Authentication Information in the Script

```python
from britive.britive import Britive
import json

britive = Britive(tenant='example', token='...') # source token and tenant locally (not from environment variables)

print(json.dumps(britive.users.list(), indent=2, default=str))
```

### Create API Token for a Service Identity

```python
from britive.britive import Britive
import json

britive = Britive()  # source needed data from environment variables

print(json.dumps(britive.service_identity_tokens.create(service_identity_id='abc123'), indent=2, default=str))
```

### Run a Report (JSON and CSV output)

```python
from britive.britive import Britive
import json

britive = Britive()  # source needed data from environment variables

print(json.dumps(britive.reports.run(report_id='abc123'), indent=2, default=str))

with open('file.csv', 'w') as f:
    f.write(britive.reports.run(report_id='abc123', csv=True))
```

### Create a Profile Policy (profiles v2/enhanced profiles)

The commands below will create a policy on a profile that allows `user@domain.com` to check out the profile but only if
`approver@domain.com` approves that request within 10 minutes.

```python
from britive.britive import Britive

b = Britive()

policy = b.profiles.policies.build(
    name='example',
    users=['user@domain.com'],
    approval_notification_medium='Email',
    approver_users=['approver@domain.com'],
    time_to_approve=10
)

b.profiles.policies.create(profile_id='...', policy=policy)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "britive",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "britive, cpam, identity, jit",
    "author": null,
    "author_email": "\"Britive Inc.\" <support@britive.com>",
    "download_url": "https://files.pythonhosted.org/packages/a8/d1/24cb2615b1e53bfa5a456cbdfa4613a5d3591e1c9fbf36a009708ff02555/britive-3.1.0.tar.gz",
    "platform": null,
    "description": "# Britive Python SDK\n\nPure Python implementation for interacting with the [Britive API](https://docs.britive.com/v1/docs/en/overview-britive-apis).\n\nThis package aims to wrap the Britive API for usage in Python development. For the most part it is a simple wrapper\n(sending potentially bad parameters to the API) but there are a couple of places where liberties were taken to enhance\nthe developer/end user experience. Some APIs may also be combined into one Python method with a parameter if and where\nit makes more sense to present the API that way.\n\nThis package supports Python versions `>= 3.8`.\n\n## Installation\n\n```sh\npip install britive\n```\n\nOr execute one of the following commands if you wish to pull directly from the Github repo instead of PyPi. Or navigate\nto Releases and use the URL of the tarball release that is needed, if not the lastest.\n\n```sh\npip install $(curl -s https://api.github.com/repos/britive/python-sdk/releases/latest \\\n    | jq -r '.assets[] | select(.content_type == \"application/x-gzip\") | .browser_download_url')\n\nOR\n\npip install $(curl -s https://api.github.com/repos/britive/python-sdk/releases/latest \\\n    | grep \"browser_download_url.*.tar.gz\" | cut -d : -f 2,3 | tr -d \\\")\n```\n\n## Documentation\n\nEach public method is documented with a docstring which provides details on what the method does, the parameters the\nmethod accepts, and details about what is returned from the method.\n\nOfficial API documentation can be found here: [Overview of Britive APIs](https://docs.britive.com/v1/docs/en/overview-britive-apis).\n\n## Authentication\n\nAuthentication is handled solely via API tokens. The token must be provided in one of two methods.\n\n1. Passed directly into the class constructor.\n2. Injected as an environment variable into the execution context where this package is being run.\n    1. The environment variable name must be `BRITIVE_API_TOKEN`.\n\n> _As of `v2.5.0` a `Bearer` token can be provided as well._\n> _A `Bearer` token is generated as part of an interactive login process and is temporary in nature._\n> _This is to support the [Britive Python CLI](https://github.com/britive/python-cli/)._\n\nAll Britive API tokens are authenticated against a specific Britive tenant. The name of the tenant must be presented in\none of two methods.\n\n1. Passed directly into the `Britive` class constructor.\n2. Injected as an environment variable into the execution context where this package is being run.\n    1. The environment variable name must be `BRITIVE_TENANT`.\n\n> _In order to obtain the tenant name, reference the Britive URL used to log into the UI._\n> _If the URL is `https://example.britive-app.com` then the tenant name will be `example`._\n\n## Pagination\n\nAll pagination is handled by the package. The caller will never have to deal with paginated responses.\n\n## Assumptions\n\n* The caller has access to an active Britive tenant.\n* The caller has been granted an API token and/or has the ability to generate an API token.\n  * This can be either for a _User_ or _Service Identity_.\n* No assumptions are made about the operating system or file system.\n  * Nothing is persisted to disk.\n    * The end user must persist responses to disk if and when that is required.\n\n## Resource Coverage\n\nThe following Britive resources are supported with full CRUDL operations where appropriate, and additional actions where\nthey exist.\n\n* Access Broker\n* Access Builder\n* Accounts\n* Accounts (associated with an application/environment)\n* API Tokens (for Users)\n* Applications\n* Audit Logs\n* Environment\n* Environment Groups\n* Groups (associated with an application/environment)\n* Identity Attributes\n* Identity Providers\n* My Access (access granted to the given identity (user or service))\n* My Resources (access granted to the given identity (user or service))\n* My Secrets (access granted to the given identity (user or service))\n* Notifications\n* Permissions (associated with an application/environment)\n* Profiles\n* Reports\n* SAML Settings\n* Scans\n* Security Policies\n* Service Identities\n* Service Identity Tokens\n* System Announcement (aka banner)\n* Tags (aka User Tags)\n* Task Services\n* Tasks\n* Users\n\n## Proxies\n\nUnder the covers, python [`requests`](https://github.com/psf/requests) is being used to communicate with the Britive API.\nAs such, any functionality of `requests` can be used, including setting an HTTP proxy.\n\n* HTTP proxies will be set via environment variables.\n  * `HTTP_PROXY`\n  * `HTTPS_PROXY`\n  * `NO_PROXY`\n  * `http_proxy`\n  * `https_proxy`\n  * `no_proxy`\n\n> _Standard HTTP proxy URLs should be utilized._\n>\n> _Examples:_\n>\n> * _Unauthenticated Proxy: `http://internalproxy.domain.com:8080`_\n> * _Authenticated Proxy: `http://user:pass@internalproxy.domain.com:8080`_\n\n## Custom TLS Certificates\n\nSetting custom TLS certificates functionality of `requests` can also be used.\n\n* Certificate bundles can be set via environment variables.\n  * `REQUESTS_CA_BUNDLE`\n  * `CURL_CA_BUNDLE` _(used as a fallback)_\n  * `PYBRITIVE_CA_BUNDLE` _(specific to the Britive Python SDK)_\n\n> _The values of these environment variables must be a path to a directory of certificates or a specific certificate._\n>\n> _Example:_\n> _`/path/to/certfile`_\n\n### Platform Examples\n\n#### linux/macos\n\n```sh\nexport REQUESTS_CA_BUNDLE=\"/usr/local/corp-proxy/cacert.pem\"\n```\n\n#### windows\n\n__powershell:__\n\n```pwsh\n$env:REQUESTS_CA_BUNDLE = \"C:\\Users\\User\\AppData\\Local\\corp-proxy\\cacert.pem\"\n```\n\n__cmd:__\n\n```bat\nset REQUESTS_CA_BUNDLE=\"C:\\Users\\User\\AppData\\Local\\corp-proxy\\cacert.pem\"\n```\n\n## Examples\n\n### Importing\n\nThis should be the only class that is required for import.\n\n```python\nfrom britive.britive import Britive\n```\n\nOptionally, the various exceptions that this package raises can be imported as well, e.g.\n\n```python\nfrom britive import exceptions\n```\n\nThen specific exception(s) could be referenced as demonstrated below:\n\n```python\ntry:\n    something()\nexcept exceptions.TokenMissingError():\n    handle()\n```\n\n### List All Users\n\n```python\nfrom britive.britive import Britive\nimport json\n\nbritive = Britive()  # source needed data from environment variables\n\nprint(json.dumps(britive.users.list(), indent=2, default=str))\n```\n\n### Provide Needed Authentication Information in the Script\n\n```python\nfrom britive.britive import Britive\nimport json\n\nbritive = Britive(tenant='example', token='...') # source token and tenant locally (not from environment variables)\n\nprint(json.dumps(britive.users.list(), indent=2, default=str))\n```\n\n### Create API Token for a Service Identity\n\n```python\nfrom britive.britive import Britive\nimport json\n\nbritive = Britive()  # source needed data from environment variables\n\nprint(json.dumps(britive.service_identity_tokens.create(service_identity_id='abc123'), indent=2, default=str))\n```\n\n### Run a Report (JSON and CSV output)\n\n```python\nfrom britive.britive import Britive\nimport json\n\nbritive = Britive()  # source needed data from environment variables\n\nprint(json.dumps(britive.reports.run(report_id='abc123'), indent=2, default=str))\n\nwith open('file.csv', 'w') as f:\n    f.write(britive.reports.run(report_id='abc123', csv=True))\n```\n\n### Create a Profile Policy (profiles v2/enhanced profiles)\n\nThe commands below will create a policy on a profile that allows `user@domain.com` to check out the profile but only if\n`approver@domain.com` approves that request within 10 minutes.\n\n```python\nfrom britive.britive import Britive\n\nb = Britive()\n\npolicy = b.profiles.policies.build(\n    name='example',\n    users=['user@domain.com'],\n    approval_notification_medium='Email',\n    approver_users=['approver@domain.com'],\n    time_to_approve=10\n)\n\nb.profiles.policies.create(profile_id='...', policy=policy)\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Britive, Inc  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A pure Python SDK for the Britive API",
    "version": "3.1.0",
    "project_urls": {
        "Changelog": "https://github.com/britive/python-sdk/blob/main/CHANGELOG.md",
        "Documentation": "https://docs.britive.com/v1/docs/en/overview-britive-apis",
        "Homepage": "https://www.britive.com",
        "Issues": "https://github.com/britive/python-sdk/issues",
        "Repository": "https://github.com/britive/python-sdk.git"
    },
    "split_keywords": [
        "britive",
        " cpam",
        " identity",
        " jit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7800e73d6ffb14612068f6673b4e7aae8d364f9b0d9d9de959529ac0d46a3166",
                "md5": "5e1c1d6f87a065a532ec3fcdcfa8a4c4",
                "sha256": "f86b0018cec0a34014284ae36f7d3403e03aa7d058db1fba44a7b65421c65cb2"
            },
            "downloads": -1,
            "filename": "britive-3.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5e1c1d6f87a065a532ec3fcdcfa8a4c4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 97338,
            "upload_time": "2024-10-08T00:58:43",
            "upload_time_iso_8601": "2024-10-08T00:58:43.360218Z",
            "url": "https://files.pythonhosted.org/packages/78/00/e73d6ffb14612068f6673b4e7aae8d364f9b0d9d9de959529ac0d46a3166/britive-3.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a8d124cb2615b1e53bfa5a456cbdfa4613a5d3591e1c9fbf36a009708ff02555",
                "md5": "c3f14f62bbce160868443838692f4a38",
                "sha256": "84fab5e42a48787554eec5870478ae39416d4bb563f45b6f1370cdb7a70d8dd7"
            },
            "downloads": -1,
            "filename": "britive-3.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c3f14f62bbce160868443838692f4a38",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 93381,
            "upload_time": "2024-10-08T00:58:45",
            "upload_time_iso_8601": "2024-10-08T00:58:45.240759Z",
            "url": "https://files.pythonhosted.org/packages/a8/d1/24cb2615b1e53bfa5a456cbdfa4613a5d3591e1c9fbf36a009708ff02555/britive-3.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-08 00:58:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "britive",
    "github_project": "python-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "britive"
}
        
Elapsed time: 0.29693s