mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-14 04:07:46 +00:00
* Add redis support for distributed caching * Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * ... and another all nighter. * fixup! ... and another all nighter. * fixup! fixup! ... and another all nighter. * fixup! fixup! fixup! ... and another all nighter. * Resolve issue #85 by adding ability to set custom claims in JWT tokens * Remove redundant validation in auth middleware ( issue #89 ) * Add ability to set cookie prefix for session cookies ( #87 ) * fixup! Add ability to set cookie prefix for session cookies ( #87 ) * Add ability to set cookie max age - issue #91 * Potential fix for code scanning alert no. 10: Size computation for allocation may overflow Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fixup! Merge main into 0.8.0-redis: resolve conflicts --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
84 lines
1.7 KiB
Go
84 lines
1.7 KiB
Go
package miniredis
|
|
|
|
// Translate the 'KEYS' or 'PSUBSCRIBE' argument ('foo*', 'f??', &c.) into a regexp.
|
|
|
|
import (
|
|
"bytes"
|
|
"regexp"
|
|
)
|
|
|
|
// patternRE compiles a glob to a regexp. Returns nil if the given
|
|
// pattern will never match anything.
|
|
// The general strategy is to sandwich all non-meta characters between \Q...\E.
|
|
func patternRE(k string) *regexp.Regexp {
|
|
re := bytes.Buffer{}
|
|
re.WriteString(`(?s)^\Q`)
|
|
for i := 0; i < len(k); i++ {
|
|
p := k[i]
|
|
switch p {
|
|
case '*':
|
|
re.WriteString(`\E.*\Q`)
|
|
case '?':
|
|
re.WriteString(`\E.\Q`)
|
|
case '[':
|
|
charClass := bytes.Buffer{}
|
|
i++
|
|
for ; i < len(k); i++ {
|
|
if k[i] == ']' {
|
|
break
|
|
}
|
|
if k[i] == '\\' {
|
|
if i == len(k)-1 {
|
|
// Ends with a '\'. U-huh.
|
|
return nil
|
|
}
|
|
charClass.WriteByte(k[i])
|
|
i++
|
|
charClass.WriteByte(k[i])
|
|
continue
|
|
}
|
|
charClass.WriteByte(k[i])
|
|
}
|
|
if charClass.Len() == 0 {
|
|
// '[]' is valid in Redis, but matches nothing.
|
|
return nil
|
|
}
|
|
re.WriteString(`\E[`)
|
|
re.Write(charClass.Bytes())
|
|
re.WriteString(`]\Q`)
|
|
|
|
case '\\':
|
|
if i == len(k)-1 {
|
|
// Ends with a '\'. U-huh.
|
|
return nil
|
|
}
|
|
// Forget the \, keep the next char.
|
|
i++
|
|
re.WriteByte(k[i])
|
|
continue
|
|
default:
|
|
re.WriteByte(p)
|
|
}
|
|
}
|
|
re.WriteString(`\E$`)
|
|
return regexp.MustCompile(re.String())
|
|
}
|
|
|
|
// matchKeys filters only matching keys.
|
|
// The returned boolean is whether the match pattern was valid
|
|
func matchKeys(keys []string, match string) ([]string, bool) {
|
|
re := patternRE(match)
|
|
if re == nil {
|
|
// Special case: the given pattern won't match anything or is invalid.
|
|
return nil, false
|
|
}
|
|
var res []string
|
|
for _, k := range keys {
|
|
if !re.MatchString(k) {
|
|
continue
|
|
}
|
|
res = append(res, k)
|
|
}
|
|
return res, true
|
|
}
|