forward_auth¶
Interface library for providing API Gateways with Identity and Access Proxy information.
It is required to integrate with OAuth2 Proxy - a reverse proxy and static file server that provides authentication using Identity Platform’s built-in identity management system and integrated identity providers (Google, GitHub, and others).
Getting Started¶
To use the library from the requirer side, add the following to the metadata.yaml of the charm:
requires:
forward-auth:
interface: forward_auth
limit: 1
Then, to initialise the library:
from charmlibs.interfaces.forward_auth import AuthConfigChangedEvent, ForwardAuthRequirer
class ApiGatewayCharm(CharmBase):
def __init__(self, *args):
# ...
self.forward_auth = ForwardAuthRequirer(self)
self.framework.observe(
self.forward_auth.on.auth_config_changed,
self.some_event_function
)
def some_event_function(self, event: AuthConfigChangedEvent):
if self.forward_auth.is_ready():
# Fetch the relation info
forward_auth_data = self.forward_auth.get_provider_info()
# update ingress configuration
# ...
- class AuthConfigChangedEvent(
- handle: Handle,
- decisions_address: str,
- app_names: list[str],
- headers: list[str],
- relation_id: int,
- relation_app_name: str,
Bases:
EventBaseEvent to notify the requirer charm that the forward-auth config has changed.
- class AuthConfigRemovedEvent(handle: Handle, relation_id: int)¶
Bases:
EventBaseEvent to notify the requirer charm that the forward-auth config was removed.
- class ForwardAuthConfig(decisions_address: str, app_names: list[str], headers: list[str] = <factory>)¶
Bases:
objectHelper class containing configuration required by API Gateway to set up the proxy.
- classmethod from_dict( ) ForwardAuthConfig¶
Generate ForwardAuthConfig instance from dict.
- exception ForwardAuthConfigError¶
Bases:
ExceptionEmitted when invalid forward auth config is provided.
- class ForwardAuthProvider(
- charm: CharmBase,
- relation_name: str = 'forward-auth',
- forward_auth_config: ForwardAuthConfig | None = None,
Bases:
ForwardAuthRelationProvider side of the forward-auth relation.
- on¶
Event descriptor for events raised by ForwardAuthProvider.
- class ForwardAuthProxySet(handle: Handle)¶
Bases:
EventBaseEvent to notify the charm that the proxy was set successfully.
- class ForwardAuthRelationRemovedEvent(handle: Handle, relation_id: int)¶
Bases:
EventBaseEvent to notify the charm that the relation was removed.
- class ForwardAuthRequirer(
- charm: CharmBase,
- *,
- relation_name: str = 'forward-auth',
- ingress_app_names: ForwardAuthRequirerConfig | None = None,
Bases:
ForwardAuthRelationRequirer side of the forward-auth relation.
- on¶
Event descriptor for events raised by ForwardAuthRequirer.
- update_requirer_relation_data(
- ingress_app_names: ForwardAuthRequirerConfig | None,
- relation_id: int | None = None,
Update the relation databag with app names that can get IAP protection.
- get_provider_info( ) ForwardAuthConfig | None¶
Get the provider information from the databag.