| 516 | } |
| 517 | |
| 518 | func (auth *AuthService) IsAuthEnabled(uri string, path config.AppPath) (bool, error) { |
| 519 | // Check for block list |
| 520 | if path.Block != "" { |
| 521 | regex, err := regexp.Compile(path.Block) |
| 522 | |
| 523 | if err != nil { |
| 524 | return true, err |
| 525 | } |
| 526 | |
| 527 | if !regex.MatchString(uri) { |
| 528 | return false, nil |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | // Check for allow list |
| 533 | if path.Allow != "" { |
| 534 | regex, err := regexp.Compile(path.Allow) |
| 535 | |
| 536 | if err != nil { |
| 537 | return true, err |
| 538 | } |
| 539 | |
| 540 | if regex.MatchString(uri) { |
| 541 | return false, nil |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | return true, nil |
| 546 | } |
| 547 | |
| 548 | func (auth *AuthService) GetBasicAuth(c *gin.Context) *config.User { |
| 549 | username, password, ok := c.Request.BasicAuth() |