Dex

Channel Revision Published Runs on
latest/candidate 66 10 Nov 2021
Ubuntu 20.04
latest/beta 507 09 Jul 2024
Ubuntu 20.04
latest/edge 607 13 Dec 2024
Ubuntu 20.04
2.39/stable 588 11 Oct 2024
Ubuntu 20.04
2.39/edge 588 11 Oct 2024
Ubuntu 20.04
2.36/stable 422 23 Feb 2024
Ubuntu 20.04
2.36/edge 572 27 Aug 2024
Ubuntu 20.04
2.31/stable 389 12 Dec 2023
Ubuntu 20.04
2.31/beta 224 28 Mar 2023
Ubuntu 20.04
2.31/edge 389 12 Dec 2023
Ubuntu 20.04
juju deploy dex-auth --channel 2.39/stable
Show information

Platform:

charms.dex_auth.v0.dex_oidc_config

Library for sharing Dex's OIDC configuration with OIDC clients.

This library offers a Python API for providing and requesting information about Dex's OIDC configuration. The default relation name is dex-oidc-config and it's recommended to use that name, though if changed, you must ensure to pass the correct name when instantiating the provider and requirer classes, as well as in metadata.yaml.

Getting Started
Fetching the library with charmcraft

Using charmcraft you can:

charmcraft fetch-lib charms.dex_auth.v0.dex_oidc_config


## Using the library as requirer

### Add relation to metadata.yaml
```yaml
requires:
  dex-oidc-config:
    interface: dex-oidc-config
    limit: 1
Instantiate the DexOidcConfigRequirer class in charm.py
from ops.charm import CharmBase
from charms.dex_auth.v0.dex_oidc_config import DexOidcConfigRequirer, DexOidcConfigRelationError

class RequirerCharm(CharmBase):
    def __init__(self, *args):
        self._dex_oidc_config_requirer = DexOidcConfigRequirer(self)
        self.framework.observe(self.on.some_event_emitted, self.some_event_function)
        self.framework.observe(self._dex_oidc_config_requirer.on.update, self.some_event_function)

    def some_event_function():
        # use the getter function wherever the info is needed
        try:
            k8s_svc_info_data = self._dex_oidc_config_requirer.get_data()
        except DexOidcConfigRelationError as error:
            "your error handler goes here"
Using the library as provider
Add relation to metadata.yaml
provides:
  dex-oidc-config:
    interface: dex-oidc-config
Instantiate the DexOidcConfigProvider class in charm.py
from ops.charm import CharmBase
from charms.dex_auth.v0.dex_oidc_config import DexOidcConfigProvider, DexOidcConfigRelationError

class ProviderCharm(CharmBase):
    def __init__(self, *args, **kwargs):
        ...
        self._dex_oidc_config_provider = DexOidcConfigProvider(self)
        self.observe(self.on.some_event, self._some_event_handler)

    def _some_event_handler(self, ...):
        # This will update the relation data bag with the issuer URL 
        try:
            self._dex_oidc_config_provider.send_data(issuer_url)
        except DexOidcConfigRelationError as error:
            "your error handler goes here"

Alternatively, if the provider is just broadcasting known data, it can be:

from ops.charm import CharmBase
from charms.dex_auth.v0.dex_oidc_config import DexOidcConfigProvider, DexOidcConfigRelationError

class ProviderCharm(CharmBase):
    def __init__(self, *args, **kwargs):
        ...
        self._dex_oidc_config_provider = DexOidcConfigProvider(self)
Relation data

The data shared by this library is:

  • issuer-url: the canonical URL for the issuer, OIDC cliets use this to refer to Dex

class DexOidcConfigRelationError

Description

Base exception class for any relation error handled by this library. None

class DexOidcConfigRelationMissingError

Description

Exception to raise when the relation is missing on either end. None

Methods

DexOidcConfigRelationMissingError. __init__( self )

class DexOidcConfigRelationDataMissingError

Description

Exception to raise when there is missing data in the relation data bag. None

Methods

DexOidcConfigRelationDataMissingError. __init__( self , message )

class DexOidcConfigUpdatedEvent

Description

Indicates the Dex OIDC config data was updated. None

class DexOidcConfigEvents

Description

Events for the Dex OIDC config library. None

class DexOidcConfigObject

Representation of a Dex OIDC config object.

Arguments

issuer_url

This is the canonical URL that OIDC clients MUST use to refer to dex.

class DexOidcConfigRequirer

Implement the Requirer end of the Dex OIDC config relation.

Arguments

charm (CharmBase)

the provider application

refresh_events

(list, optional): list of BoundEvents that this manager should handle. Use this to update the data sent on this relation on demand.

relation_name (str)

the name of the relation

Attributes

charm (CharmBase)
variable for storing the requirer application
relation_name (str)
variable for storing the name of the relation

Description

This library emits:

  • DexOidcConfigUpdatedEvent: when data received on the relation is updated.

Methods

DexOidcConfigRequirer. __init__( self , charm: CharmBase , refresh_events , relation_name )

DexOidcConfigRequirer. get_data( self )

Description

Return a DexOidcConfigObject. None

class DexOidcConfigRequirerWrapper

Wrapper for the relation data getting logic.

Arguments

charm (CharmBase)

the requirer application

relation_name (str)

the name of the relation

Attributes

relation_name (str)
variable for storing the name of the relation

Methods

DexOidcConfigRequirerWrapper. __init__( self , charm , relation_name )

DexOidcConfigRequirerWrapper. get_data( self )

Return a DexOidcConfigObject containing Dex's OIDC configuration.

class DexOidcConfigProvider

Implement the Provider end of the Dex OIDC config relation.

Arguments

charm (CharmBase)

the provider application

issuer_url (str)

This is the canonical URL that OIDC clients MUST use to refer to dex.

refresh_events

(list, optional): list of BoundEvents that this manager should handle. Use this to update the data sent on this relation on demand.

relation_name (str)

the name of the relation

Attributes

charm (CharmBase)
variable for storing the provider application
relation_name (str)
variable for storing the name of the relation

Description

Observes relation events to send data to related applications.

Methods

DexOidcConfigProvider. __init__( self , charm: CharmBase , issuer_url: str , refresh_events , relation_name )

class DexOidcConfigProviderWrapper

Wrapper for the relation data sending logic.

Arguments

charm (CharmBase)

the provider application

relation_name (str)

the name of the relation

Attributes

charm (CharmBase)
variable for storing the provider application
relation_name (str)
variable for storing the name of the relation

Methods

DexOidcConfigProviderWrapper. __init__( self , charm: CharmBase , relation_name )

DexOidcConfigProviderWrapper. send_data( self , issuer_url: str )

Update the relation data bag with data from Dex's OIDC configuration.

Arguments

issuer_url (str)

This is the canonical URL that OIDC clients MUST use to refer to dex.

Description

This method will complete successfully even if there are no related applications.