SAML Integrator

  • By Canonical IS DevOps
Channel Revision Published Runs on
latest/stable 48 02 Apr 2024
Ubuntu 22.04
latest/edge 50 03 May 2024
Ubuntu 22.04
juju deploy saml-integrator
Show information

Platform:

Ubuntu
22.04

charms.saml_integrator.v0.saml

Library to manage the relation data for the SAML Integrator charm.

This library contains the Requires and Provides classes for handling the relation between an application and a charm providing the samlrelation. It also contains a SamlRelationData class to wrap the SAML data that will be shared via the relation.

Requirer Charm

from charms.saml_integrator.v0 import SamlDataAvailableEvent, SamlRequires

class SamlRequirerCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.saml = saml.SamlRequires(self)
        self.framework.observe(self.saml.on.saml_data_available, self._handler)
        ...

    def _handler(self, events: SamlDataAvailableEvent) -> None:
        ...

As shown above, the library provides a custom event to handle the scenario in which new SAML data has been added or updated.

Provider Charm

Following the previous example, this is an example of the provider charm.

from charms.saml_integrator.v0 import SamlDataAvailableEvent, SamlRequires

class SamlRequirerCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.saml = SamlRequires(self)
        self.framework.observe(self.saml.on.saml_data_available, self._on_saml_data_available)
        ...

    def _on_saml_data_available(self, events: SamlDataAvailableEvent) -> None:
        ...

    def __init__(self, *args):
        super().__init__(*args)
        self.saml = SamlProvides(self)

The SamlProvides object wraps the list of relations into a relations property and provides an update_relation_data method to update the relation data by passing a SamlRelationData data object. Additionally, SamlRelationData can be used to directly parse the relation data with the class method from_relation_data.


class SamlEndpoint

Represent a SAML endpoint.

Description

Attrs: name: Endpoint name. url: Endpoint URL. binding: Endpoint binding. response_url: URL to address the response to.

Methods

SamlEndpoint. to_relation_data( self )

Convert an instance of SamlEndpoint to the relation representation.

Returns

Dict containing the representation.

SamlEndpoint. from_relation_data( cls , relation_data )

Initialize a new instance of the SamlEndpoint class from the relation data.

Arguments

relation_data

the relation data.

Returns

A SamlEndpoint instance.

class SamlRelationData

Represent the relation data.

Description

Attrs: entity_id: SAML entity ID. metadata_url: URL to the metadata. certificates: Tuple of SAML certificates. endpoints: Tuple of SAML endpoints.

Methods

SamlRelationData. to_relation_data( self )

Convert an instance of SamlDataAvailableEvent to the relation representation.

Returns

Dict containing the representation.

SamlRelationData. from_relation_data( cls , relation_data )

Get a SamlRelationData wrapping the relation data.

Arguments

relation_data

the relation data.

class SamlDataAvailableEvent

Saml event emitted when relation data has changed.

Description

Attrs: saml_relation_data: the SAML relation data entity_id: SAML entity ID. metadata_url: URL to the metadata. certificates: Tuple containing the SAML certificates. endpoints: Tuple containing the SAML endpoints.

Methods

SamlDataAvailableEvent. saml_relation_data( self )

Description

Get a SamlRelationData for the relation data. None

SamlDataAvailableEvent. entity_id( self )

Description

Fetch the SAML entity ID from the relation. None

SamlDataAvailableEvent. metadata_url( self )

Description

Fetch the SAML metadata URL from the relation. None

SamlDataAvailableEvent. certificates( self )

Description

Fetch the SAML certificates from the relation. None

SamlDataAvailableEvent. endpoints( self )

Description

Fetch the SAML endpoints from the relation. None

class SamlRequiresEvents

SAML events.

Description

This class defines the events that a SAML requirer can emit.

Attrs: saml_data_available: the SamlDataAvailableEvent.

class SamlRequires

Requirer side of the SAML relation.

Description

Attrs: on: events the provider can emit.

Methods

SamlRequires. __init__( self , charm , relation_name: str )

Construct.

Arguments

charm

the provider charm.

relation_name

the relation name.

SamlRequires. get_relation_data( self )

Retrieve the relation data.

Returns

SmtpRelationData

the relation data.

class SamlProvides

Provider side of the SAML relation.

Description

Attrs: relations: list of charm relations.

Methods

SamlProvides. __init__( self , charm , relation_name: str )

Construct.

Arguments

charm

the provider charm.

relation_name

the relation name.

SamlProvides. relations( self )

The list of Relation instances associated with this relation_name.

Returns

List of relations to this charm.

SamlProvides. update_relation_data( self , relation , saml_data: SamlRelationData )

Update the relation data.

Arguments

relation

the relation for which to update the data.

saml_data

a SamlRelationData instance wrapping the data to be updated.