2020-02-18 22:15:09 +00:00
|
|
|
package authorization
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/authelia/authelia/internal/utils"
|
|
|
|
)
|
|
|
|
|
2020-06-25 08:22:42 +00:00
|
|
|
func isSubjectMatching(subject Subject, subjectRule []string) bool {
|
|
|
|
for _, ruleSubject := range subjectRule {
|
|
|
|
if strings.HasPrefix(ruleSubject, userPrefix) {
|
|
|
|
user := strings.Trim(ruleSubject[len(userPrefix):], " ")
|
|
|
|
if user == subject.Username {
|
|
|
|
continue
|
|
|
|
}
|
2020-02-18 22:15:09 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 08:22:42 +00:00
|
|
|
if strings.HasPrefix(ruleSubject, groupPrefix) {
|
|
|
|
group := strings.Trim(ruleSubject[len(groupPrefix):], " ")
|
|
|
|
if utils.IsStringInSlice(group, subject.Groups) {
|
|
|
|
continue
|
|
|
|
}
|
2020-02-18 22:15:09 +00:00
|
|
|
}
|
2020-06-25 08:22:42 +00:00
|
|
|
|
|
|
|
return false
|
2020-02-18 22:15:09 +00:00
|
|
|
}
|
2020-05-05 19:35:32 +00:00
|
|
|
|
2020-06-25 08:22:42 +00:00
|
|
|
return true
|
2020-02-18 22:15:09 +00:00
|
|
|
}
|