Contains the Concourse pipeline definition for building a line-server container
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
492 B

  1. package main
  2. import (
  3. "net/http"
  4. "strings"
  5. )
  6. func strictReferrerCheck(r *http.Request, prefix string, whitelistHeaders []string) bool {
  7. p := strings.TrimSuffix(prefix, "/")
  8. if origin := r.Header.Get("Origin"); origin != "" && !strings.HasPrefix(origin, p) {
  9. return false
  10. }
  11. for _, header := range whitelistHeaders {
  12. if r.Header.Get(header) != "" {
  13. return true
  14. }
  15. }
  16. if referrer := r.Header.Get("Referer"); !strings.HasPrefix(referrer, p) {
  17. return false
  18. }
  19. return true
  20. }