Skip to content

Commit

Permalink
fixup! submit: add support for checking imat tokens
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Nov 13, 2023
1 parent 39150bc commit 3245980
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ type submitResponse struct {
IssueNumber string `json:"issue_number,omitempty"`
}

var gplaySpamEmailRegex = regexp.MustCompile(`^[a-z]+.\d{5}@gmail\.com$`)

func (s *submitServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// if we attempt to return a response without reading the request body,
// apache gets upset and returns a 500. Let's try this.
Expand Down Expand Up @@ -371,6 +373,14 @@ func (s *submitServer) parseRequest(w http.ResponseWriter, req *http.Request, re
if !hasUserID {
return p
} else if p.AppName == "booper" {
if gplaySpamEmailRegex.MatchString(p.Data["user_id"]) {
log.Println("Dropping report from", p.Data["user_id"])
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
_, _ = w.Write([]byte("{}"))
return nil
}

whoami, err := s.verifyIMAToken(req.Context(), req.Header.Get("Authorization"), userID)
if err != nil {
log.Printf("Error verifying user ID (%s): %v", userID, err)
Expand Down

0 comments on commit 3245980

Please sign in to comment.