MCPcopy
hub / github.com/tinyauthapp/tinyauth / CheckFilter

Function CheckFilter

internal/utils/security_utils.go:78–103  ·  view source on GitHub ↗
(filter string, str string)

Source from the content-addressed store, hash-verified

76}
77
78func CheckFilter(filter string, str string) bool {
79 if len(strings.TrimSpace(filter)) == 0 {
80 return true
81 }
82
83 if strings.HasPrefix(filter, "/") && strings.HasSuffix(filter, "/") {
84 re, err := regexp.Compile(filter[1 : len(filter)-1])
85 if err != nil {
86 return false
87 }
88
89 if re.MatchString(strings.TrimSpace(str)) {
90 return true
91 }
92 }
93
94 filterSplit := strings.Split(filter, ",")
95
96 for _, item := range filterSplit {
97 if strings.TrimSpace(item) == strings.TrimSpace(str) {
98 return true
99 }
100 }
101
102 return false
103}
104
105func GenerateUUID(str string) string {
106 uuid := uuid.NewSHA1(uuid.NameSpaceURL, []byte(str))

Callers 5

TestCheckFilterFunction · 0.92
IsEmailWhitelistedMethod · 0.92
IsUserAllowedMethod · 0.92
IsInOAuthGroupMethod · 0.92
IsInLdapGroupMethod · 0.92

Calls

no outgoing calls

Tested by 1

TestCheckFilterFunction · 0.74