matcher.go 361 B

1234567891011121314151617181920212223
  1. package perm
  2. import (
  3. "path/filepath"
  4. "github.com/ory/ladon"
  5. )
  6. type PathMatcher struct {
  7. }
  8. func (m *PathMatcher) Matches(p ladon.Policy, haystack []string, needle string) (bool, error) {
  9. for _, h := range haystack {
  10. m, err := filepath.Match(h, needle)
  11. if err != nil {
  12. return false, err
  13. }
  14. if m {
  15. return true, nil
  16. }
  17. }
  18. return false, nil
  19. }