From 81ad829b63c48bf1c6eef92fc43c4deaaf890e9a Mon Sep 17 00:00:00 2001 From: Mateusz Canova Date: Sun, 13 Mar 2022 14:13:59 +0100 Subject: [PATCH] Pulling all atrributes from SAML --- samlsp/session.go | 12 ++++++++++++ samlsp/session_jwt.go | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/samlsp/session.go b/samlsp/session.go index 87b659bd..95d21f16 100644 --- a/samlsp/session.go +++ b/samlsp/session.go @@ -87,3 +87,15 @@ func AttributeFromContext(ctx context.Context, name string) string { } return sa.GetAttributes().Get(name) } + +func GetAllAttributesFromContext(ctx context.Context, name string) []string { + s := SessionFromContext(ctx) + if s == nil { + return []string{""} + } + sa, ok := s.(SessionWithAttributes) + if !ok { + return []string{""} + } + return sa.GetAttributes().GetAll(name) +} diff --git a/samlsp/session_jwt.go b/samlsp/session_jwt.go index ed485bbd..59fb9c46 100644 --- a/samlsp/session_jwt.go +++ b/samlsp/session_jwt.go @@ -145,3 +145,11 @@ func (a Attributes) Get(key string) string { } return v[0] } + +func (a Attributes) GetAll(key string) []string { + if a == nil { + return []string{""} + } + v := a[key] + return v +}