Add client ID and client secret to OIDC config validator
This commit is contained in:
parent
6c7b6101cc
commit
ed3da4697f
2 changed files with 13 additions and 0 deletions
|
@ -9,6 +9,9 @@ from util.config.validators.validate_oidc import OIDCLoginValidator
|
|||
|
||||
@pytest.mark.parametrize('unvalidated_config', [
|
||||
({'SOMETHING_LOGIN_CONFIG': {}}),
|
||||
({'SOMETHING_LOGIN_CONFIG': {'OIDC_SERVER': 'foo'}}),
|
||||
({'SOMETHING_LOGIN_CONFIG': {'OIDC_SERVER': 'foo', 'CLIENT_ID': 'foobar'}}),
|
||||
({'SOMETHING_LOGIN_CONFIG': {'OIDC_SERVER': 'foo', 'CLIENT_SECRET': 'foobar'}}),
|
||||
])
|
||||
def test_validate_invalid_oidc_login_config(unvalidated_config):
|
||||
validator = OIDCLoginValidator()
|
||||
|
@ -30,6 +33,8 @@ def test_validate_oidc_login():
|
|||
validator = OIDCLoginValidator()
|
||||
validator.validate({
|
||||
'SOMETHING_LOGIN_CONFIG': {
|
||||
'CLIENT_ID': 'foo',
|
||||
'CLIENT_SECRET': 'bar',
|
||||
'OIDC_SERVER': 'http://someserver',
|
||||
'DEBUGGING': True, # Allows for HTTP.
|
||||
},
|
||||
|
|
|
@ -18,6 +18,14 @@ class OIDCLoginValidator(BaseValidator):
|
|||
msg = 'Missing OIDC_SERVER on OIDC service %s' % service.service_id()
|
||||
raise ConfigValidationException(msg)
|
||||
|
||||
if service.config.get('CLIENT_ID') is None:
|
||||
msg = 'Missing CLIENT_ID on OIDC service %s' % service.service_id()
|
||||
raise ConfigValidationException(msg)
|
||||
|
||||
if service.config.get('CLIENT_SECRET') is None:
|
||||
msg = 'Missing CLIENT_SECRET on OIDC service %s' % service.service_id()
|
||||
raise ConfigValidationException(msg)
|
||||
|
||||
try:
|
||||
if not service.validate():
|
||||
msg = 'Could not validate OIDC service %s' % service.service_id()
|
||||
|
|
Reference in a new issue