Glauth K8S
- Identity Charmers
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 16 | 20 May 2024 | |
latest/edge | 32 | Yesterday |
juju deploy glauth-k8s
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Platform:
charms.glauth_k8s.v0.ldap
-
- Last updated 02 Sep 2024
- Revision Library version 0.6
Juju Charm Library for the ldap
Juju Interface.
This juju charm library contains the Provider and Requirer classes for handling
the ldap
interface.
Requirer Charm
The requirer charm is expected to:
- Provide information for the provider charm to deliver LDAP related information in the juju integration, in order to communicate with the LDAP server and authenticate LDAP operations
- Listen to the custom juju event
LdapReadyEvent
to obtain the LDAP related information from the integration - Listen to the custom juju event
LdapUnavailableEvent
to handle the situation when the LDAP integration is broken
from charms.glauth_k8s.v0.ldap import (
LdapRequirer,
LdapReadyEvent,
LdapUnavailableEvent,
)
class RequirerCharm(CharmBase):
# LDAP requirer charm that integrates with an LDAP provider charm.
def __init__(self, *args):
super().__init__(*args)
self.ldap_requirer = LdapRequirer(self)
self.framework.observe(
self.ldap_requirer.on.ldap_ready,
self._on_ldap_ready,
)
self.framework.observe(
self.ldap_requirer.on.ldap_unavailable,
self._on_ldap_unavailable,
)
def _on_ldap_ready(self, event: LdapReadyEvent) -> None:
# Consume the LDAP related information
ldap_data = self.ldap_requirer.consume_ldap_relation_data(
relation=event.relation,
)
# Configure the LDAP requirer charm
...
def _on_ldap_unavailable(self, event: LdapUnavailableEvent) -> None:
# Handle the situation where the LDAP integration is broken
...
As shown above, the library offers custom juju events to handle specific situations, which are listed below:
- ldap_ready: event emitted when the LDAP related information is ready for requirer charm to use.
- ldap_unavailable: event emitted when the LDAP integration is broken.
Additionally, the requirer charmed operator needs to declare the ldap
interface in the metadata.yaml
:
requires:
ldap:
interface: ldap
Provider Charm
The provider charm is expected to:
- Use the information provided by the requirer charm to provide LDAP related information for the requirer charm to connect and authenticate to the LDAP server
- Listen to the custom juju event
LdapRequestedEvent
to offer LDAP related information in the integration
from charms.glauth_k8s.v0.ldap import (
LdapProvider,
LdapRequestedEvent,
)
class ProviderCharm(CharmBase):
# LDAP provider charm.
def __init__(self, *args):
super().__init__(*args)
self.ldap_provider = LdapProvider(self)
self.framework.observe(
self.ldap_provider.on.ldap_requested,
self._on_ldap_requested,
)
def _on_ldap_requested(self, event: LdapRequestedEvent) -> None:
# Consume the information provided by the requirer charm
requirer_data = event.data
# Prepare the LDAP related information using the requirer's data
ldap_data = ...
# Update the integration data
self.ldap_provider.update_relations_app_data(
relation.id,
ldap_data,
)
As shown above, the library offers custom juju events to handle specific situations, which are listed below:
- ldap_requested: event emitted when the requirer charm is requesting the LDAP related information in order to connect and authenticate to the LDAP server
Index
def leader_unit(func: Callable)
Methods
leader_unit. wrapper( obj )
class Secret
Methods
Secret. __init__( self , secret )
Secret. uri( self )
Secret. load( cls , charm: CharmBase , label: str )
Secret. create_or_update( cls , charm: CharmBase , label: str , content )
Secret. grant( self , relation: Relation )
Secret. remove( self )
class LdapProviderBaseData
Methods
LdapProviderBaseData. validate_ldap_urls( cls , vs )
LdapProviderBaseData. serialize_list( self , urls )
LdapProviderBaseData. deserialize_bool( cls , v )
LdapProviderBaseData. serialize_bool( self , starttls: bool )
class LdapProviderData
class LdapRequirerData
class LdapRequestedEvent
Description
An event emitted when the LDAP integration is built. None
Methods
LdapRequestedEvent. data( self )
class LdapProviderEvents
class LdapReadyEvent
Description
An event when the LDAP related information is ready. None
class LdapUnavailableEvent
Description
An event when the LDAP integration is unavailable. None
class LdapRequirerEvents
class LdapProvider
Methods
LdapProvider. __init__( self , charm: CharmBase , relation_name: str )
LdapProvider. get_bind_password( self , relation_id: int )
Description
Retrieve the bind account password for a given integration. None
LdapProvider. update_relations_app_data( relation_id )
Description
An API for the provider charm to provide the LDAP related information. None
class LdapRequirer
Description
An LDAP requirer to consume data delivered by an LDAP provider charm. None
Methods
LdapRequirer. __init__( self , charm: CharmBase , relation_name: str )
LdapRequirer. consume_ldap_relation_data( relation , relation_id )
Description
An API for the requirer charm to consume the LDAP related information in the application databag. None
LdapRequirer. relations( self )
Description
The list of Relation instances associated with this relation_name. None
LdapRequirer. ready( self , relation_id )
Check if the resource has been created.
Arguments
When provided the check is done only for the relation id provided, otherwise the check is done for all relations
Returns
True or False
Description
This function can be used to check if the Provider answered with data in the charm code when outside an event callback.