Skip to content

Commit

Permalink
Format using Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
malexmave committed Sep 18, 2024
1 parent c6de7a4 commit bb6ce2e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ def should_consider_client(self, client) -> bool:
# We are interested in clients that are:
# - OIDC Clients
# - Confidential Clients
return (self.is_not_ignored(client)
and not client.is_realm_specific_client()
and client.is_oidc_client()
and not client.is_public())
return (
self.is_not_ignored(client)
and not client.is_realm_specific_client()
and client.is_oidc_client()
and not client.is_public()
)

def client_does_not_use_mtls_or_jwt_auth(self, client) -> bool:
# If the clientAuthenticatorType is client-secret, basic client secret authentication is used.
Expand Down
6 changes: 5 additions & 1 deletion kcwarden/auditors/client/client_with_full_scope_allowed.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ class ClientWithFullScopeAllowed(Auditor):
REFERENCE = ""

def should_consider_client(self, client) -> bool:
return self.is_not_ignored(client) and client.allows_user_authentication() and not client.is_realm_specific_client()
return (
self.is_not_ignored(client)
and client.allows_user_authentication()
and not client.is_realm_specific_client()
)

def client_has_full_scope_allowed(self, client) -> bool:
return client.has_full_scope_allowed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ def should_consider_client(self, client) -> bool:
# We are interested in clients that are:
# - OIDC clients
# - Are confidential clients
return (self.is_not_ignored(client)
and not client.is_realm_specific_client()
and client.is_oidc_client()
and not client.is_public()
return (
self.is_not_ignored(client)
and not client.is_realm_specific_client()
and client.is_oidc_client()
and not client.is_public()
)

def client_uses_direct_access_grants(self, client) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ def should_consider_client(self, client) -> bool:
# We are interested in clients that are:
# - OIDC clients
# - Are public clients
return (self.is_not_ignored(client)
and not client.is_realm_specific_client()
and client.is_oidc_client()
and client.is_public()
return (
self.is_not_ignored(client)
and not client.is_realm_specific_client()
and client.is_oidc_client()
and client.is_public()
)

def client_uses_direct_access_grants(self, client) -> bool:
Expand Down
6 changes: 1 addition & 5 deletions kcwarden/custom_types/keycloak_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,7 @@ def is_realm_specific_client(self) -> bool:
# management permissions. These clients behave differently from other
# clients, so we need to exclude them from some of our standard checks.
return (
self.get_realm().get_name() == "master"
and self.get_name().endswith("-realm")
and "protocol" not in self._d
self.get_realm().get_name() == "master" and self.get_name().endswith("-realm") and "protocol" not in self._d
)

def get_protocol(self) -> str:
Expand All @@ -531,8 +529,6 @@ def get_protocol(self) -> str:
# we'd like to know about it. Raise an exception.
raise RuntimeError("'protocol' field of Client {} is not set, aborting".format(self.get_name()))



def is_oidc_client(self) -> bool:
return self.get_protocol() == "openid-connect"

Expand Down

0 comments on commit bb6ce2e

Please sign in to comment.