Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add anonymousdse_enabled config option #79

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ config:
Enable the StartTLS support or not. DO NOT TURN IT OFF IN PRODUCTION.
default: true
type: boolean
anonymousdse_enabled:
description: |
Allow anonymous requests to the root directory server agent service entry (root DSE).

Anonymous request MUST be enabled for applications like SSSD to
successfully bind to the Glauth server. Anonymous requests should
be disabled if not integrating with applications that must first
anonymously query the root DSE before binding to an LDAP server.
default: false
type: boolean


base: ubuntu@22.04
Expand Down
2 changes: 2 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def __init__(self, *args: Any):

self.config_file = ConfigFile(
base_dn=self.config.get("base_dn"),
anonymousdse_enabled=self.config.get("anonymousdse_enabled"),
starttls_config=StartTLSConfig.load(self.config),
)
self._ldap_integration = LdapIntegration(self)
Expand Down Expand Up @@ -237,6 +238,7 @@ def _on_database_changed(self, event: DatabaseEndpointsChangedEvent) -> None:

def _on_config_changed(self, event: ConfigChangedEvent) -> None:
self.config_file.base_dn = self.config.get("base_dn")
self.config_file.anonymousdse_enabled = self.config.get("anonymousdse_enabled")
self._handle_event_update(event)
self.ldap_provider.update_relations_app_data(self._ldap_integration.provider_base_data)

Expand Down
2 changes: 2 additions & 0 deletions src/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def load(cls, config: Mapping[str, Any]) -> "StartTLSConfig":
@dataclass
class ConfigFile:
base_dn: Optional[str] = None
anonymousdse_enabled: bool = False
database_config: Optional[DatabaseConfig] = None
starttls_config: Optional[StartTLSConfig] = None
ldap_servers_config: Optional[LdapServerConfig] = None
Expand All @@ -95,6 +96,7 @@ def render(self) -> str:
starttls_config = asdict(self.starttls_config) if self.starttls_config else None
rendered = template.render(
base_dn=self.base_dn,
anonymousdse_enabled=self.anonymousdse_enabled,
database=database_config,
ldap_servers=ldap_servers_config,
starttls=starttls_config,
Expand Down
1 change: 1 addition & 0 deletions templates/glauth.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ structuredlog = true
pluginhandler = "NewPostgresHandler"
baseDN = "{{ base_dn }}"
database = "postgres://{{ database.get('username') }}:{{ database.get('password') }}@{{ database.get('endpoint') }}/{{ database.get('database') }}?sslmode=disable"
anonymousdse = {{ "true" if anonymousdse_enabled else "false" }}
{% endif %}

[behaviors]
Expand Down