mirror of https://github.com/dexidp/dex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
453 B
18 lines
453 B
|
7 years ago
|
package groups
|
||
|
|
|
||
|
|
// Filter filters out any groups of given that are not in required. Thus it may
|
||
|
|
// happen that the resulting slice is empty.
|
||
|
|
func Filter(given, required []string) []string {
|
||
|
|
groups := []string{}
|
||
|
|
groupFilter := make(map[string]struct{})
|
||
|
|
for _, group := range required {
|
||
|
|
groupFilter[group] = struct{}{}
|
||
|
|
}
|
||
|
|
for _, group := range given {
|
||
|
|
if _, ok := groupFilter[group]; ok {
|
||
|
|
groups = append(groups, group)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return groups
|
||
|
|
}
|