(r *http.Request)
| 15 | const AuthKeyHeader = "X-AuthKey" |
| 16 | |
| 17 | func ValidateIncomingRequest(r *http.Request) error { |
| 18 | reqAuthKey := r.Header.Get(AuthKeyHeader) |
| 19 | if reqAuthKey == "" { |
| 20 | return fmt.Errorf("no x-authkey header") |
| 21 | } |
| 22 | if reqAuthKey != GetAuthKey() { |
| 23 | return fmt.Errorf("x-authkey header is invalid") |
| 24 | } |
| 25 | return nil |
| 26 | } |
| 27 | |
| 28 | func SetAuthKeyFromEnv() error { |
| 29 | authkey = os.Getenv(WaveAuthKeyEnv) |
no test coverage detected