No project description provided
Project description
Globus Identity Mapper
The Globus Identity Mapper Python library provides two mapping classes that implement configurable hooks for mapping a Globus Auth Identity resource to an application- or context-specific username:
ExpressionIdentityMapping
ExternalIdentityMapping
Additionally, the library offers a protocol for implementing custom identity mapper logic:
IdentityMappingProtocol
Most consumers of this library will make use of a mapping configuration
document, the .from_mapping_document()
method to instantiate the appropriate
class, and then call .map_identity()
or .map_identities()
thereafter.
This enables administrators to dynamically specify their desired mapping
configuration without having to resort to typing Python code. For example, a
simple mapping configuration to use the ExpressionIdentityMapping
logic to
follow the rules as documented at Globus Connect Server, Identity Mapping
might be:
{
"DATA_TYPE": "expression_identity_mapping#1.0.0",
"mappings": [
{
"source": "{email}", "match": "(.*)@example\\.org", "output": "{0}"
}
]
}
A hard-coded class instantiation might look like:
>>> import json
>>> from globus_identity_mapping import ExpressionIdentityMapping
>>> fdata = open("example_configuration.json").read()
>>> mapping_document = json.loads(fdata)
>>> connector_id = "..." # see the Identity Mapping Guide, linked above
>>> storage_gateway = "application-specific-identifier"
>>> mapper = ExpressionIdentityMapping.from_mapping_document(
... mapping_document, storage_gateway=storage_gateway, connector_id=connector_id
... )
Thereafter, the mapper
may be used to find a context-aware username by
mapping the source field of email
from a Globus Auth Identity record via
the regular expression logic. (In the above example, the hostname is stripped
to determine the application-specific username.) Example:
>>> gair = {"id": "...", "sub": "...", "email": "billy@example.org", "name": "..."}
>>> mapper.map_identity(gair)
'billy'
For more serious library usage, implements may want to look at
globus_identity_mapping.loader.load_mappers
Development
The high level bits:
- uses Poetry (
pyproject.toml
) - uses tox
tox
- enough to run all teststox -e mypy
to run mypy
- Reminder to install
pre-commit
at your first checkout:pre-commit --install
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file globus_identity_mapping-0.4.0.tar.gz
.
File metadata
- Download URL: globus_identity_mapping-0.4.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.6 Linux/6.8.0-48-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | acd8c2efdb7f7c2d3a4e26dcce1a053e9081da903b1815a12164c3433aa66ddb |
|
MD5 | b96db91e36d54fd55eda31af164ff957 |
|
BLAKE2b-256 | cd56a9fdd4430c1ee4bf2eeb0f3d80ace4438ded0cf2f9f3fa73fb31a32b60dd |
File details
Details for the file globus_identity_mapping-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: globus_identity_mapping-0.4.0-py3-none-any.whl
- Upload date:
- Size: 26.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.6 Linux/6.8.0-48-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e44ce34db273c593afd337ef1a175e96336a9a3413863246c74e8427f135016a |
|
MD5 | e661fbb1d66be00f96960d68d7e876cf |
|
BLAKE2b-256 | 9b720d5f231d3205f92980394fa917fcb26f781d2a8e41669ed017a51d02ae40 |