---
title: Charmhub | Deploy Dex using Charmhub - The Open Operator Collection
description: Deploy the latest version of Dex as a Kubernetes Operator on any cloud.
url: https://charmhub.io/dex-auth/libraries/dex_oidc_config
---

# Dex

[Kubeflow Charmers](https://charmhub.io/publisher/ckfbot "View all packages from Kubeflow Charmers")

* [Kubeflow Charmers](https://charmhub.io/publisher/ckfbot "View all packages from Kubeflow Charmers")
* [Containers](https://charmhub.io/?filter=containers)
* [Security](https://charmhub.io/?filter=security)

Platform:

2.41/stable 815

```
juju deploy dex-auth --channel 2.41/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/dex-auth/libraries/dex_oidc_config#drawer)

## charms.dex\_auth.v0.dex\_oidc\_config

* [*Docstrings*Docstrings](https://charmhub.io/dex-auth/libraries/dex_oidc_config)
  [*Code*Source code](https://charmhub.io/dex-auth/libraries/dex_oidc_config/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.dex_auth.v0.dex_oidc_config
    ```

    [Download dex\_oidc\_config.py](https://charmhub.io/dex-auth/libraries/dex_oidc_config/download)
  + *Last updated* 25 Jul 2024
  + *Revision* Library version 0.1

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

---

Index

* [class DexOidcConfigRelationError](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrelationerror)
* [class DexOidcConfigRelationMissingError](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrelationmissingerror)
* + [def \_\_init\_\_(
    self)](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrelationmissingerror-__init__)
* [class DexOidcConfigRelationDataMissingError](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrelationdatamissingerror)
* + [def \_\_init\_\_(
    self,
    message)](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrelationdatamissingerror-__init__)
* [class DexOidcConfigUpdatedEvent](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigupdatedevent)
* [class DexOidcConfigEvents](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigevents)
* [class DexOidcConfigObject](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigobject)
* [class DexOidcConfigRequirer](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrequirer)
* + [def \_\_init\_\_(
    self,
    charm,
    refresh\_events,
    relation\_name)](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrequirer-__init__)
* + [def get\_data(
    self)](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrequirer-get_data)
* [class DexOidcConfigRequirerWrapper](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrequirerwrapper)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrequirerwrapper-__init__)
* + [def get\_data(
    self)](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigrequirerwrapper-get_data)
* [class DexOidcConfigProvider](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigprovider)
* + [def \_\_init\_\_(
    self,
    charm,
    issuer\_url,
    refresh\_events,
    relation\_name)](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigprovider-__init__)
* [class DexOidcConfigProviderWrapper](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigproviderwrapper)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigproviderwrapper-__init__)
* + [def send\_data(
    self,
    issuer\_url)](https://charmhub.io/dex-auth/libraries/dex_oidc_config#dexoidcconfigproviderwrapper-send_data)

#### 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.
