mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
1600e0f7da
* [CI] Add wsl linter * Implement wsl recommendations Co-authored-by: Clément Michaud <clement.michaud34@gmail.com>
31 lines
630 B
Go
31 lines
630 B
Go
package authorization
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/authelia/authelia/internal/utils"
|
|
)
|
|
|
|
func isSubjectMatching(subject Subject, subjectRule string) bool {
|
|
// If no subject is provided in the rule, we match any user.
|
|
if subjectRule == "" {
|
|
return true
|
|
}
|
|
|
|
if strings.HasPrefix(subjectRule, userPrefix) {
|
|
user := strings.Trim(subjectRule[len(userPrefix):], " ")
|
|
if user == subject.Username {
|
|
return true
|
|
}
|
|
}
|
|
|
|
if strings.HasPrefix(subjectRule, groupPrefix) {
|
|
group := strings.Trim(subjectRule[len(groupPrefix):], " ")
|
|
if utils.IsStringInSlice(group, subject.Groups) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|