From 717cae5c0b4ddc52b68fcf893304ba012f30156e Mon Sep 17 00:00:00 2001 From: Peter Grlica Date: Mon, 10 Jan 2022 10:16:00 +0100 Subject: [PATCH] Added support for SAML HTTP binding --- auth/auth.go | 2 ++ auth/saml/saml.go | 1 + auth/saml/sp.go | 8 ++++++++ auth/settings/settings.go | 3 +++ system/types/app_settings.go | 3 +++ 5 files changed, 17 insertions(+) diff --git a/auth/auth.go b/auth/auth.go index 04ab71323..092e638b6 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -300,6 +300,8 @@ func (svc *service) LoadSamlService(ctx context.Context, s *settings.Settings) ( SignRequests: s.Saml.SignRequests, SignatureMethod: s.Saml.SignMethod, + Binding: s.Saml.Binding, + IdentityPayload: saml.IdpIdentityPayload{ Name: s.Saml.IDP.IdentName, Handle: s.Saml.IDP.IdentHandle, diff --git a/auth/saml/saml.go b/auth/saml/saml.go index dbb18f199..6722a9c82 100644 --- a/auth/saml/saml.go +++ b/auth/saml/saml.go @@ -48,6 +48,7 @@ func UpdateSettings(source *types.AppSettings, dest *settings.Settings) { dest.Saml.Key = saml.Key dest.Saml.SignRequests = saml.SignRequests dest.Saml.SignMethod = saml.SignMethod + dest.Saml.Binding = saml.Binding dest.Saml.IDP.URL = saml.IDP.URL dest.Saml.IDP.IdentName = saml.IDP.IdentName diff --git a/auth/saml/sp.go b/auth/saml/sp.go index 5b4e75a27..b84ac9b77 100644 --- a/auth/saml/sp.go +++ b/auth/saml/sp.go @@ -40,6 +40,8 @@ type ( SignRequests bool SignatureMethod string + Binding string + // user meta from idp IdentityPayload IdpIdentityPayload @@ -72,6 +74,11 @@ func NewSamlSPService(log *zap.Logger, args SamlSPArgs) (s *SamlSPService, err e sp.SignatureMethod = args.SignatureMethod } + // default to GET + if args.Binding == "" { + args.Binding = saml.HTTPRedirectBinding + } + opts := samlsp.Options{ URL: args.Host, Key: sp.Key, @@ -88,6 +95,7 @@ func NewSamlSPService(log *zap.Logger, args SamlSPArgs) (s *SamlSPService, err e handler.RequestTracker = samlsp.DefaultRequestTracker(opts, &handler.ServiceProvider) handler.ServiceProvider = sp + handler.Binding = args.Binding s = &SamlSPService{ log: log, diff --git a/auth/settings/settings.go b/auth/settings/settings.go index 1d20045fb..05fb9db43 100644 --- a/auth/settings/settings.go +++ b/auth/settings/settings.go @@ -32,6 +32,9 @@ type ( // Signature method for signing SignMethod string + // Post or redirect binding + Binding string + // Identity provider hostname IDP struct { URL string diff --git a/system/types/app_settings.go b/system/types/app_settings.go index c1915b14f..685e9db02 100644 --- a/system/types/app_settings.go +++ b/system/types/app_settings.go @@ -107,6 +107,9 @@ type ( // Signature method for signing SignMethod string `kv:"sign-method"` + // Post or redirect binding + Binding string `kv:"binding"` + // Identity provider settings IDP struct { URL string `kv:"url"`