fe21f43911
docker/libtrust repository has been archived for several years now. This commit replaces all the libtrust JWT machinery with go-jose/go-jose module. Some of the code has been adopted from libtrust and adjusted for some of the use cases covered by the token authorization flow especially in the tests. Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
38 lines
756 B
Go
38 lines
756 B
Go
package token
|
|
|
|
// actionSet is a special type of stringSet.
|
|
type actionSet struct {
|
|
stringSet
|
|
}
|
|
|
|
func newActionSet(actions ...string) actionSet {
|
|
return actionSet{newStringSet(actions...)}
|
|
}
|
|
|
|
// Contains calls StringSet.Contains() for
|
|
// either "*" or the given action string.
|
|
func (s actionSet) contains(action string) bool {
|
|
return s.stringSet.contains("*") || s.stringSet.contains(action)
|
|
}
|
|
|
|
// contains returns true if q is found in ss.
|
|
func contains(ss []string, q string) bool {
|
|
for _, s := range ss {
|
|
if s == q {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// containsAny returns true if any of q is found in ss.
|
|
func containsAny(ss []string, q []string) bool {
|
|
for _, s := range ss {
|
|
if contains(q, s) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|