charmlibs-interfaces-oauth 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,187 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+ cos-tool*
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .coverage-*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+ .report/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ #uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ #poetry.lock
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ #pdm.lock
115
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
116
+ # in version control.
117
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
118
+ .pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
123
+ __pypackages__/
124
+
125
+ # Celery stuff
126
+ celerybeat-schedule
127
+ celerybeat.pid
128
+
129
+ # SageMath parsed files
130
+ *.sage.py
131
+
132
+ # Environments
133
+ .env
134
+ .venv
135
+ env/
136
+ venv/
137
+ ENV/
138
+ env.bak/
139
+ venv.bak/
140
+
141
+ # Spyder project settings
142
+ .spyderproject
143
+ .spyproject
144
+
145
+ # Rope project settings
146
+ .ropeproject
147
+
148
+ # mkdocs documentation
149
+ /site
150
+
151
+ # mypy
152
+ .mypy_cache/
153
+ .dmypy.json
154
+ dmypy.json
155
+
156
+ # Pyre type checker
157
+ .pyre/
158
+
159
+ # pytype static type analyzer
160
+ .pytype/
161
+
162
+ # Cython debug symbols
163
+ cython_debug/
164
+
165
+ # PyCharm
166
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
167
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
168
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
169
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
170
+ .idea/
171
+
172
+ # PyPI configuration file
173
+ .pypirc
174
+
175
+ # packed charms
176
+ .packed
177
+
178
+ # temporary directory for packing charms
179
+ .tmp
180
+
181
+ # uv.lock from example libraries as we don't commit these
182
+ .example/**/uv.lock
183
+ .tutorial/**/uv.lock
184
+ interfaces/.example/**/uv.lock
185
+
186
+ # Workshop lock file (machine-local state)
187
+ .workshop.lock
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ Initial release. Migrated from `charms.hydra.v0.oauth` (v0.12).
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: charmlibs-interfaces-oauth
3
+ Version: 1.0.0
4
+ Summary: The charmlibs.interfaces.oauth package.
5
+ Project-URL: Documentation, https://canonical.com/juju/docs/charmlibs/reference/charmlibs/interfaces/oauth
6
+ Project-URL: Repository, https://github.com/canonical/charmlibs/tree/main/interfaces/oauth
7
+ Project-URL: Issues, https://github.com/canonical/charmlibs/issues
8
+ Project-URL: Changelog, https://github.com/canonical/charmlibs/blob/main/interfaces/oauth/CHANGELOG.md
9
+ Author: Identity Team at Canonical
10
+ License-Expression: Apache-2.0
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: jsonschema>=4.26.0
17
+ Requires-Dist: ops<4,>=2.23.1
18
+ Description-Content-Type: text/markdown
19
+
20
+ # charmlibs.interfaces.oauth
21
+
22
+ The `oauth` interface library.
23
+
24
+ To install, add `charmlibs-interfaces-oauth` to your Python dependencies. Then in your Python code, import as:
25
+
26
+ ```py
27
+ from charmlibs.interfaces import oauth
28
+ ```
29
+
30
+ See the [reference documentation](https://canonical.com/juju/docs/charmlibs/reference/charmlibs/interfaces/oauth) for more.
@@ -0,0 +1,11 @@
1
+ # charmlibs.interfaces.oauth
2
+
3
+ The `oauth` interface library.
4
+
5
+ To install, add `charmlibs-interfaces-oauth` to your Python dependencies. Then in your Python code, import as:
6
+
7
+ ```py
8
+ from charmlibs.interfaces import oauth
9
+ ```
10
+
11
+ See the [reference documentation](https://canonical.com/juju/docs/charmlibs/reference/charmlibs/interfaces/oauth) for more.
@@ -0,0 +1,85 @@
1
+ # `oauth/v0`
2
+
3
+ ## Overview
4
+
5
+ This relation interface describes the expected behavior of any charm claiming to be able to interface with an OAuth2/OIDC Provider.
6
+
7
+ ## Usage
8
+
9
+ Charms claiming to provide this interface must implement the OAuth2/OIDC protocol and register a client for each relation. In most cases, this will be accomplished using the [oauth](https://charmhub.io/hydra/libraries/oauth) library, although charm developers are free to provide alternative libraries as long as they fulfill the behavioral and schematic requirements described in this document.
10
+
11
+ ## Direction
12
+
13
+ The `oauth` interface implements a provider/requirer pattern.
14
+ The requirer is a charm that wishes to act as a oauth2 client, and the provider is a charm exposing an OAuth2/OIDC provider.
15
+
16
+ ```mermaid
17
+ flowchart TD
18
+ Requirer -- redirect_uri, audience, scope, grant_types, token_endpoint_auth_method --> Provider
19
+ Provider -- issuer_url, authentication_endpoint, token_endpoint, userinfo_endpoint, introspection_endpoint, jwks_endpoint, client_id, client_secret_id, scope, groups --> Requirer
20
+ ```
21
+
22
+ ## Behavior
23
+
24
+ The requirer and the provider must adhere to a certain set of criteria to be considered compatible with the interface.
25
+
26
+ ### Provider
27
+
28
+ - Is expected to provide its endpoints (`authentication_endpoint`, `token_endpoint`, `userinfo_endpoint`, `introspection_endpoint` and `jwks_endpoint`) in the relation databag.
29
+ - Is expected to provide the `issuer_url` in the relation databag.
30
+ - Is expected to provide the supported scopes in the databag.
31
+ - Is expected to register a client and provide the `client_id` in the databag.
32
+ - Is expected to register a client, place the `client_secret` in a juju secret and provide the juju secret ID in the databag (`client_secret_id`).
33
+ - Is expected to provide the groups claim, if one is available.
34
+
35
+ As mentioned above the field `client_secret_id` holds the id of a Juju Secret, this means that the charms implementing the relation must be running on Juju >3 in order be able to use Juju secrets.
36
+
37
+ ### Requirer
38
+
39
+ - Is expected to provide a user accessible `redirect_uri` using the HTTPS scheme.
40
+ - Is expected to provide an audience for the issued tokens, if extra audience are required.
41
+ - Is expected to provide the `grant_types` and `token_endpoint_auth_method` it wishes to use.
42
+ - Is expected to provide the scopes that should be allowed for this client.
43
+
44
+ ## Relation Data
45
+
46
+ ### Provider
47
+
48
+ [\[JSON Schema\]](./schemas/provider.json)
49
+
50
+ Provider provides its endpoints, configurations and the client credentials. It should be placed in the **application** databag.
51
+
52
+ #### Example
53
+
54
+ ```yaml
55
+ related-units: {}
56
+ application_data: {
57
+ "issuer_url": "https://auth_server_public_url/",
58
+ "authorization_endpoint": "https://auth_server_public_url/authorize",
59
+ "token_endpoint": "https://auth_server_public_url/token",
60
+ "introspection_endpoint": "https://auth_server_public_url/introspect",
61
+ "userinfo_endpoint": "https://auth_server_public_url/userinfo",
62
+ "jwks_endpoint": "https://auth_server_public_url/jwks",
63
+ "scope": "openid profile email phone",
64
+ "client_id": "some_id",
65
+ "client_secret_id": "42174217421742",
66
+ }
67
+ ```
68
+
69
+ ### Requirer
70
+
71
+ [\[JSON Schema\]](./schemas/requirer.json)
72
+
73
+ Requirer requires its client configurations. It should be placed in the **application** databag.
74
+
75
+ #### Example
76
+ ```yaml
77
+ related-units: {}
78
+ application-data: {
79
+ "redirect_uri": "https://some_url/callback",
80
+ "audience": [],
81
+ "scope": "openid email",
82
+ "grant_types": ["authorization_code"],
83
+ "token_endpoint_auth_method": "client_secret_basic"
84
+ }
85
+ ```
@@ -0,0 +1,18 @@
1
+ name: oauth
2
+ version: 0
3
+ status: draft
4
+ lib: charmlibs.interfaces.oauth
5
+ summary: Connect to an OAuth2/OIDC Provider.
6
+ description: |
7
+ The `oauth` interface allows charms to interface with an OAuth2/OIDC Provider.
8
+ The requirer acts as an OAuth2 client.
9
+ The provider exposes an OAuth2/OIDC Provider.
10
+
11
+ providers:
12
+ - name: hydra-operator
13
+ url: https://www.github.com/canonical/hydra-operator
14
+
15
+ requirers:
16
+ []
17
+
18
+ maintainer: identity
@@ -0,0 +1,122 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://canonical.github.io/charm-relation-interfaces/interfaces/oauth/schemas/provider.json",
4
+ "type": "object",
5
+ "title": "`oauth` provider schema",
6
+ "description": "The `oauth` root schema comprises the entire provider databag for this interface.",
7
+ "default": {},
8
+ "examples": [
9
+ {
10
+ "application-data": {
11
+ "issuer_url": "https://auth_server_public_url/",
12
+ "authorization_endpoint": "https://auth_server_public_url/authorize",
13
+ "token_endpoint": "https://auth_server_public_url/token",
14
+ "introspection_endpoint": "https://auth_server_public_url/introspect",
15
+ "userinfo_endpoint": "https://auth_server_public_url/userinfo",
16
+ "jwks_endpoint": "https://auth_server_public_url/jwks",
17
+ "scope": "openid profile email phone",
18
+ "client_id": "some_id",
19
+ "client_secret_id": "42174217421742"
20
+ },
21
+ "related-units": {}
22
+ }
23
+ ],
24
+ "properties": {
25
+ "application-data": {
26
+ "$id": "#/properties/application-data",
27
+ "title": "Application Databag",
28
+ "type": "object",
29
+ "additionalProperties": true,
30
+ "properties": {
31
+ "issuer_url": {
32
+ "type": "string",
33
+ "title": "Issuer URL",
34
+ "description": "The OpenID Connect identity provider's issuer URL.",
35
+ "examples": [
36
+ "https://some_url/"
37
+ ]
38
+ },
39
+ "authorization_endpoint": {
40
+ "type": "string",
41
+ "title": "Authorization Endpoint",
42
+ "description": "The OpenID Connect identity provider's authorization endpoint URL.",
43
+ "examples": [
44
+ "https://some_url/authorize"
45
+ ]
46
+ },
47
+ "token_endpoint": {
48
+ "type": "string",
49
+ "title": "Token Endpoint",
50
+ "description": "The OpenID Connect identity provider's token endpoint URL.",
51
+ "examples": [
52
+ "https://some_url/token"
53
+ ]
54
+ },
55
+ "introspection_endpoint": {
56
+ "type": "string",
57
+ "title": "Introspection Endpoint",
58
+ "description": "The OpenID Connect identity provider's introspection endpoint URL.",
59
+ "examples": [
60
+ "https://some_url/introspect"
61
+ ]
62
+ },
63
+ "userinfo_endpoint": {
64
+ "type": "string",
65
+ "title": "Userinfo Endpoint",
66
+ "description": "The OpenID Connect identity provider's Userinfo Userinfo URL.",
67
+ "examples": [
68
+ "https://some_url/userinfo"
69
+ ]
70
+ },
71
+ "jwks_endpoint": {
72
+ "type": "string",
73
+ "title": "JWKS Endpoint",
74
+ "description": "The OpenID Connect identity provider's jwks endpoint URL.",
75
+ "examples": [
76
+ "https://some_url/jwks"
77
+ ]
78
+ },
79
+ "scope": {
80
+ "type": "string",
81
+ "title": "Scope",
82
+ "description": "A space-separated list with the OpenID Connect identity provider's supported scopes."
83
+ },
84
+ "client_id": {
85
+ "type": "string",
86
+ "title": "Client ID",
87
+ "description": "The client_id."
88
+ },
89
+ "client_secret_id": {
90
+ "type": "string",
91
+ "title": "Juju secret ID",
92
+ "description": "The juju secret ID that holds the client_secret."
93
+ },
94
+ "groups": {
95
+ "type": "string",
96
+ "title": "Groups Claim Name",
97
+ "description": "The name of the claim that represents the user's groups",
98
+ "default": null
99
+ }
100
+ },
101
+ "required": [
102
+ "issuer_url",
103
+ "authorization_endpoint",
104
+ "token_endpoint",
105
+ "introspection_endpoint",
106
+ "userinfo_endpoint",
107
+ "jwks_endpoint",
108
+ "scope",
109
+ "client_id"
110
+ ]
111
+ },
112
+ "related-units": {
113
+ "type": "object",
114
+ "patternProperties": {
115
+ "^.*/d+$": {
116
+ "type": "object",
117
+ "additionalProperties": true
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
@@ -0,0 +1,91 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://canonical.github.io/charm-relation-interfaces/interfaces/oauth/schemas/requirer.json",
4
+ "type": "object",
5
+ "title": "`oauth` requirer schema",
6
+ "description": "The `oauth` root schema comprises the entire requirer databag for this interface.",
7
+ "default": {},
8
+ "examples": [
9
+ {
10
+ "application-data": {
11
+ "redirect_uri": "https://some_url/callback",
12
+ "audience": [],
13
+ "scope": "openid email",
14
+ "grant_types": ["authorization_code"],
15
+ "token_endpoint_auth_method": ["client_secret_basic"]
16
+ },
17
+ "related-units": {}
18
+ }
19
+ ],
20
+ "properties": {
21
+ "application-data": {
22
+ "$id": "#/properties/application-data",
23
+ "title": "Application Databag",
24
+ "type": "object",
25
+ "additionalProperties": true,
26
+ "properties": {
27
+ "redirect_uri": {
28
+ "type": "string",
29
+ "title": "Redirect URI",
30
+ "description": "The client's redirect_uri, must be using the HTTPS scheme.",
31
+ "default": null,
32
+ "examples": [
33
+ "https://some_url/callback"
34
+ ]
35
+ },
36
+ "audience": {
37
+ "type": "array",
38
+ "title": "Audience",
39
+ "description": "List of audience the client will be allowed to request.",
40
+ "default": [],
41
+ "items": {
42
+ "type": "string"
43
+ }
44
+ },
45
+ "scope": {
46
+ "type": "string",
47
+ "title": "Scope",
48
+ "description": "The scopes the client wishes to use, must be a space-separated subset of the Provider's allowed scope.",
49
+ "default": null
50
+ },
51
+ "grant_types": {
52
+ "type": "array",
53
+ "title": "Grant Types",
54
+ "description": "The grant types the client wishes to use, must be a subset of the Provider's allowed grant types.",
55
+ "default": null,
56
+ "items": {
57
+ "enum": ["authorization_code", "client_credentials", "refresh_token", "urn:ietf:params:oauth:grant-type:device_code"],
58
+ "type": "string"
59
+ }
60
+ },
61
+ "token_endpoint_auth_method": {
62
+ "type": "string",
63
+ "enum": ["client_secret_basic", "client_secret_post"],
64
+ "title": "Token Endpoint Client Authentication Methods",
65
+ "description": "The client authentication methods the clients wishes to use, it must be a subset of the supported client authentication methods of the Provider.",
66
+ "default": "client_secret_basic"
67
+ }
68
+ },
69
+ "required": [
70
+ "redirect_uri",
71
+ "audience",
72
+ "scope",
73
+ "grant_types",
74
+ "token_endpoint_auth_method"
75
+ ]
76
+ },
77
+ "related-units": {
78
+ "type": "object",
79
+ "patternProperties": {
80
+ "^.*/d+$": {
81
+ "type": "object",
82
+ "additionalProperties": true
83
+ }
84
+ }
85
+ }
86
+ },
87
+ "required": [
88
+ "application-data",
89
+ "related-units"
90
+ ]
91
+ }
@@ -0,0 +1,83 @@
1
+ [project]
2
+ name = "charmlibs-interfaces-oauth"
3
+ description = "The charmlibs.interfaces.oauth package."
4
+ readme = "README.md"
5
+ requires-python = ">=3.10"
6
+ authors = [
7
+ {name="Identity Team at Canonical"},
8
+ ]
9
+ license = "Apache-2.0"
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Intended Audience :: Developers",
13
+ "Operating System :: POSIX :: Linux",
14
+ "Development Status :: 5 - Production/Stable",
15
+ ]
16
+ dynamic = ["version"]
17
+ dependencies = [
18
+ # Libraries should use clear but wide dependency bounds to avoid overly constraining charms.
19
+ # Ops 3 is backwards compatible with Ops 2, but drops Python 3.8 support.
20
+ # Ops 3 has new features not present in Ops 2.23 (the last Ops 2 feature release).
21
+ # See the Ops 2.23 maintenance branch changelog and the Ops 3 changelog for current information:
22
+ # - https://github.com/canonical/operator/blob/2.23-maintenance/CHANGES.md
23
+ # - https://github.com/canonical/operator/blob/main/CHANGES.md
24
+ # Set the dependency bounds according to the features and fixes your library needs.
25
+ "jsonschema>=4.26.0",
26
+ "ops>=2.23.1,<4",
27
+ ]
28
+
29
+
30
+ [dependency-groups]
31
+ lint = [ # installed for `just lint interfaces/oauth` (unit, functional, and integration are also installed)
32
+ # "typing_extensions",
33
+ ]
34
+ unit = [ # installed for `just unit interfaces/oauth`
35
+ "ops[testing]",
36
+ ]
37
+ functional = [ # installed for `just functional interfaces/oauth`
38
+ ]
39
+ integration = [ # installed for `just integration interfaces/oauth`
40
+ "jubilant",
41
+ ]
42
+
43
+ [project.urls]
44
+ "Documentation" = "https://canonical.com/juju/docs/charmlibs/reference/charmlibs/interfaces/oauth"
45
+ "Repository" = "https://github.com/canonical/charmlibs/tree/main/interfaces/oauth"
46
+ "Issues" = "https://github.com/canonical/charmlibs/issues"
47
+ "Changelog" = "https://github.com/canonical/charmlibs/blob/main/interfaces/oauth/CHANGELOG.md"
48
+
49
+ [build-system]
50
+ requires = ["hatchling"]
51
+ build-backend = "hatchling.build"
52
+
53
+ [tool.hatch.build.targets.wheel]
54
+ packages = ["src/charmlibs"]
55
+
56
+ [tool.hatch.version]
57
+ path = "src/charmlibs/interfaces/oauth/_version.py"
58
+
59
+
60
+ [tool.ruff]
61
+ extend = "../../pyproject.toml"
62
+ src = ["src", "tests/unit", "tests/functional", "tests/integration"] # correctly sort local imports in tests
63
+
64
+ [tool.ruff.lint.extend-per-file-ignores]
65
+ # add additional per-file-ignores here to avoid overriding repo-level config
66
+ "tests/**/*" = [
67
+ # "E501", # line too long
68
+ ]
69
+
70
+ [tool.pyright]
71
+ extends = "../../pyproject.toml"
72
+ include = ["src", "tests"]
73
+ pythonVersion = "3.10" # check no python > 3.10 features are used
74
+
75
+ [tool.charmlibs.functional]
76
+ ubuntu = [] # ubuntu versions to run functional tests with, e.g. "24.04" (defaults to just "latest")
77
+ pebble = [] # pebble versions to run functional tests with, e.g. "v1.0.0", "master" (defaults to no pebble versions)
78
+ sudo = false # whether to run functional tests with sudo (defaults to false)
79
+
80
+ [tool.charmlibs.integration]
81
+ # tags to run integration tests with (defaults to running once with no tag, i.e. tags = [''])
82
+ # Available in CI in tests/integration/pack.sh and integration tests as CHARMLIBS_TAG
83
+ tags = [] # Not used by the pack.sh and integration tests generated by the template