From 9ad18d68c81d9dbb43605c459a030d1644819355 Mon Sep 17 00:00:00 2001 From: guyp-descope Date: Tue, 18 Jul 2023 11:36:02 +0300 Subject: [PATCH 1/3] Fix logger and service providers fields initialization (when not using the default New function) --- samlidp/samlidp.go | 6 ++++++ samlidp/service.go | 3 +++ 2 files changed, 9 insertions(+) diff --git a/samlidp/samlidp.go b/samlidp/samlidp.go index 13ca10b9..771aab60 100644 --- a/samlidp/samlidp.go +++ b/samlidp/samlidp.go @@ -80,6 +80,12 @@ func New(opts Options) (*Server, error) { return s, nil } +func (s *Server) InitializeLogger(logger logger.Interface) { + if s != nil { + s.logger = logger + } +} + // InitializeHTTP sets up the HTTP handler for the server. (This function // is called automatically for you by New, but you may need to call it // yourself if you don't create the object using New.) diff --git a/samlidp/service.go b/samlidp/service.go index 0b62cd3b..cc0a97f5 100644 --- a/samlidp/service.go +++ b/samlidp/service.go @@ -93,6 +93,9 @@ func (s *Server) HandlePutService(c web.C, w http.ResponseWriter, r *http.Reques } s.idpConfigMu.Lock() + if s.serviceProviders == nil { + s.serviceProviders = map[string]*saml.EntityDescriptor{} + } s.serviceProviders[service.Metadata.EntityID] = &service.Metadata s.idpConfigMu.Unlock() From cc416d42212e30a1fb8932d146813269a9da2860 Mon Sep 17 00:00:00 2001 From: guyp-descope Date: Tue, 18 Jul 2023 12:09:56 +0300 Subject: [PATCH 2/3] Add comment --- samlidp/samlidp.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samlidp/samlidp.go b/samlidp/samlidp.go index 771aab60..84f15f3c 100644 --- a/samlidp/samlidp.go +++ b/samlidp/samlidp.go @@ -80,6 +80,9 @@ func New(opts Options) (*Server, error) { return s, nil } +// Initialize the Server logger. (This function should be used only when +// not using the default New(opts Options) function where the logger +// object can be passed through the options) func (s *Server) InitializeLogger(logger logger.Interface) { if s != nil { s.logger = logger From 32ecadc9b2dcd8ef50a1b29fd482d235f5eac219 Mon Sep 17 00:00:00 2001 From: guyp-descope Date: Tue, 18 Jul 2023 12:11:53 +0300 Subject: [PATCH 3/3] Adjust comment to the required format --- samlidp/samlidp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samlidp/samlidp.go b/samlidp/samlidp.go index 84f15f3c..7e5b36a7 100644 --- a/samlidp/samlidp.go +++ b/samlidp/samlidp.go @@ -80,7 +80,7 @@ func New(opts Options) (*Server, error) { return s, nil } -// Initialize the Server logger. (This function should be used only when +// InitializeLogger initialize the Server logger. (This function should be used only when // not using the default New(opts Options) function where the logger // object can be passed through the options) func (s *Server) InitializeLogger(logger logger.Interface) {