providers/*: implement configuration_error

This commit is contained in:
Jens Langhammer 2020-12-27 13:13:24 +01:00
parent 7964061466
commit fc98c3934a
4 changed files with 18 additions and 0 deletions

View File

@ -230,6 +230,11 @@ class OAuth2Provider(Provider):
# if the user selected RS256 but didn't select a # if the user selected RS256 but didn't select a
# CertificateKeyPair, we fall back to HS256 # CertificateKeyPair, we fall back to HS256
if not self.rsa_key: if not self.rsa_key:
Event.new(
EventAction.CONFIGURATION_ERROR,
provider=self,
message="Provider was configured for RS256, but no key was selected.",
).save()
self.jwt_alg = JWTAlgorithms.HS256 self.jwt_alg = JWTAlgorithms.HS256
self.save() self.save()
else: else:

View File

@ -153,6 +153,13 @@ class OAuthAuthorizationParams:
if self.redirect_uri.lower() not in [ if self.redirect_uri.lower() not in [
x.lower() for x in self.provider.redirect_uris.split() x.lower() for x in self.provider.redirect_uris.split()
]: ]:
Event.new(
EventAction.CONFIGURATION_ERROR,
provider=self.provider,
message="Invalid redirect URI was used.",
client_used=self.redirect_uri,
configured=self.provider.redirect_uris.split(),
).save()
LOGGER.warning( LOGGER.warning(
"Invalid redirect uri", "Invalid redirect uri",
redirect_uri=self.redirect_uri, redirect_uri=self.redirect_uri,

View File

@ -115,6 +115,11 @@ class SAMLSSOBindingRedirectView(SAMLSSOView):
) )
self.request.session[SESSION_KEY_AUTH_N_REQUEST] = auth_n_request self.request.session[SESSION_KEY_AUTH_N_REQUEST] = auth_n_request
except CannotHandleAssertion as exc: except CannotHandleAssertion as exc:
Event.new(
EventAction.CONFIGURATION_ERROR,
provider=self.provider,
message=str(exc),
).save()
LOGGER.info(exc) LOGGER.info(exc)
return bad_request_message(self.request, str(exc)) return bad_request_message(self.request, str(exc))
return None return None

View File

@ -7011,6 +7011,7 @@ definitions:
- policy_execution - policy_execution
- policy_exception - policy_exception
- property_mapping_exception - property_mapping_exception
- configuration_error
- model_created - model_created
- model_updated - model_updated
- model_deleted - model_deleted