Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add label config #61

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ options:
The provider's ID to be used in Kratos. The redirect_uri is generated based on this.
You must not have 2 providers with the same ID registered in Kratos.
type: string
label:
description: |
The text that will be shown to the user when asked to choose a provider, defaults to the provider type
type: string
scope:
description: Space separated list of allowed scopes for the provider.
type: string
Expand Down
7 changes: 7 additions & 0 deletions integration-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# TODO: remove when new version is released
# Relevant PR https://github.com/go-macaroon-bakery/py-macaroon-bakery/pull/95
macaroonbakery==1.3.2
pytest
juju
pytest-operator>=0.28.0
-r requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _on_client_config_changed(self, event):

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 5
LIBPATCH = 6

DEFAULT_RELATION_NAME = "kratos-external-idp"
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -172,6 +172,7 @@ def _on_client_config_changed(self, event):
"scope": {"type": "string"},
"team_id": {"type": "string"},
"provider_id": {"type": "string"},
"label": {"type": "string"},
"jsonnet_mapper": {"type": "string"},
},
"additionalProperties": True,
Expand Down Expand Up @@ -260,7 +261,7 @@ class BaseProviderConfigHandler:
"""The base class for parsing a provider's config."""

mandatory_fields = {"provider", "client_id", "secret_backend", "scope"}
optional_fields = {"provider_id", "jsonnet_mapper"}
optional_fields = {"provider_id", "jsonnet_mapper", "label"}
excluded_fields = {"enabled"}
providers: List[str] = []

Expand Down Expand Up @@ -586,6 +587,7 @@ class Provider:
provider: str
relation_id: str
scope: str = "profile email address phone"
label: Optional[str] = None
client_secret: Optional[str] = None
issuer_url: Optional[str] = None
tenant_id: Optional[str] = None
Expand Down Expand Up @@ -619,6 +621,7 @@ def config(self) -> Dict:
"id": self.provider_id,
"client_id": self.client_id,
"provider": self.provider,
"label": self.label or self.provider,
"client_secret": self.client_secret,
"issuer_url": self.issuer_url,
"scope": self.scope.split(" "),
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def config() -> Dict:
"client_id": "client_id",
"client_secret": "client_secret",
"provider": "generic",
"label": "Some Provider",
"issuer_url": "http://example.com",
"secret_backend": "relation",
"scope": "profile email address phone",
Expand All @@ -31,6 +32,7 @@ def generic_databag(config: Dict) -> Dict:
{
"client_id": config["client_id"],
"provider": config["provider"],
"label": config["label"],
"secret_backend": config["secret_backend"],
"client_secret": config["client_secret"],
"issuer_url": config["issuer_url"],
Expand Down Expand Up @@ -60,6 +62,7 @@ def generic_kratos_config(config: Dict) -> Dict:
"id": "generic_c1b858ba120b6a62d17865256fab2617b727ab27",
"client_id": config["client_id"],
"provider": config["provider"],
"label": config["label"],
"client_secret": config["client_secret"],
"issuer_url": config["issuer_url"],
"scope": config["scope"].split(" "),
Expand Down
6 changes: 1 addition & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ commands =
[testenv:integration]
description = Run integration tests
deps =
pytest-asyncio==0.21.1
pytest
juju
pytest-operator>=0.13.0
-r{toxinidir}/requirements.txt
-r{toxinidir}/integration-requirements.txt
commands =
pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs}