Skip to content

Commit

Permalink
fix checking key
Browse files Browse the repository at this point in the history
  • Loading branch information
konrad2002 committed Dec 3, 2024
1 parent 937c798 commit e6d62cd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ func actuator(c *gin.Context) {

func checkServiceKey(c *gin.Context) error {
println("checking service key...")
fmt.Printf("received: '%s', expected: '%s'\n", c.Request.Header["X-SWIMRESULTS-SERVICE"][0], serviceKey)
if c.Request.Header["X-SWIMRESULTS-SERVICE"][0] == serviceKey {
received := c.Request.Header["X-SWIMRESULTS-SERVICE"]
fmt.Printf("received: '%s', expected: '%s'\n", received, serviceKey)
if len(received) <= 0 {
return errors.New("no service authorization key in header")
}
if received[0] == serviceKey {
return nil
}

return errors.New("no service authorization key in header")
return errors.New("invalid service authorization key in header")
}

func checkAuthHeaderToken(c *gin.Context) error {
Expand Down

0 comments on commit e6d62cd

Please sign in to comment.