feat: adopt domain validator in oauth controller and acls service

This commit is contained in:
Stavros
2026-07-14 00:37:22 +03:00
parent 3008ffad34
commit 0c1cc98fd3
5 changed files with 41 additions and 79 deletions
+2 -1
View File
@@ -23,6 +23,7 @@ type DomainValidatorOptions struct {
// Ensure domains have the same port.
WithPort bool
// Specify a list of allowed schemes IF WithScheme is set to true.
// Leave empty to allow any scheme.
AllowedSchemes []string
}
@@ -64,7 +65,7 @@ func (v *DomainValidator) getURL(i string) (*url.URL, error) {
if u.Scheme == "tinyauth" {
return nil, fmt.Errorf("input url is missing scheme")
}
if !slices.Contains(v.opts.AllowedSchemes, u.Scheme) {
if len(v.opts.AllowedSchemes) > 0 && !slices.Contains(v.opts.AllowedSchemes, u.Scheme) {
return nil, fmt.Errorf("scheme %s not allowed", u.Scheme)
}
}