From 23d12e9339aa1f07d9ecef2bd4b1d0da7cc18cc2 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 30 Aug 2018 12:44:55 +0200 Subject: [PATCH] config: Fix use of uninitialized logger The MustValidate() function is sometimes called before any other logging function has been called and this results in a crash. An easy way to reproduce the crash is to change OAUTH2_ACCESS_TOKEN_STRATEGY=jwt in the default docker-compose.yml Signed-off-by: Vishesh Handa --- config/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 2e9fa858f46..043fc4afb57 100644 --- a/config/config.go +++ b/config/config.go @@ -100,11 +100,11 @@ type Config struct { func (c *Config) MustValidate() { if stringslice.Has(c.GetSubjectTypesSupported(), "pairwise") && c.OAuth2AccessTokenStrategy == "jwt" { - c.logger.Fatalf(`The pairwise subject identifier algorithm is not supported by the JWT OAuth 2.0 Access Token Strategy. Please remove "pairwise" from OIDC_SUBJECT_TYPES_SUPPORTED or set OAUTH2_ACCESS_TOKEN_STRATEGY to "opaque"`) + c.GetLogger().Fatalf(`The pairwise subject identifier algorithm is not supported by the JWT OAuth 2.0 Access Token Strategy. Please remove "pairwise" from OIDC_SUBJECT_TYPES_SUPPORTED or set OAUTH2_ACCESS_TOKEN_STRATEGY to "opaque"`) } if stringslice.Has(c.GetSubjectTypesSupported(), "pairwise") && len(c.SubjectIdentifierAlgorithmSalt) < 8 { - c.logger.Fatalf(`The pairwise subject identifier algorithm was set but length of OIDC_SUBJECT_TYPE_PAIRWISE_SALT is too small (%d < 8), please set OIDC_SUBJECT_TYPE_PAIRWISE_SALT to a random string with 8 characters or more`, len(c.SubjectIdentifierAlgorithmSalt)) + c.GetLogger().Fatalf(`The pairwise subject identifier algorithm was set but length of OIDC_SUBJECT_TYPE_PAIRWISE_SALT is too small (%d < 8), please set OIDC_SUBJECT_TYPE_PAIRWISE_SALT to a random string with 8 characters or more`, len(c.SubjectIdentifierAlgorithmSalt)) } }