Skip to content

Commit

Permalink
Merge pull request #7 from amboss-mededu/pull-multiple-attributes
Browse files Browse the repository at this point in the history
Pulling all atrributes from SAML
  • Loading branch information
Canu667 authored Mar 14, 2022
2 parents 8bfe056 + 81ad829 commit fb30d1c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions samlsp/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
8 changes: 8 additions & 0 deletions samlsp/session_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit fb30d1c

Please sign in to comment.