Skip to content

Commit 1d42742

Browse files
committed
address comments
1 parent 9aa93cc commit 1d42742

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/charm.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,13 @@ def _on_config_changed(self, _: HookEvent) -> None:
200200

201201
def _on_saml_data_available(self, event: SamlDataAvailableEvent) -> None:
202202
"""Handle SAML data available."""
203-
fingerprint = hashlib.sha1(base64.b64decode(event.certificates[0])).hexdigest() # nosec
204-
relation = self.model.get_relation("saml")
205-
# Will ignore union-attr since asserting the relation type will make bandit complain.
206-
relation.data[self.app].update({"fingerprint": fingerprint}) # type: ignore[union-attr]
207-
relation.data[self.app].update({"entity_id": event.entity_id}) # type: ignore[union-attr]
208-
self._on_config_changed(event)
203+
if self.unit.is_leader():
204+
# Utilizing the SHA1 hash is safe in this case, so a nosec ignore will be put in place.
205+
fingerprint = hashlib.sha1(base64.b64decode(event.certificates[0])).hexdigest() # nosec
206+
relation = self.model.get_relation("saml")
207+
# Will ignore union-attr since asserting the relation type will make bandit complain.
208+
relation.data[self.app].update({"fingerprint": fingerprint, }) # type: ignore[union-attr]
209+
self._on_config_changed(event)
209210

210211
def _on_rolling_restart(self, _: ops.EventBase) -> None:
211212
"""Handle rolling restart event.

0 commit comments

Comments
 (0)