Skip to content

Commit

Permalink
Return an error if the wrong role is requested (fix #15)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtblin committed Dec 5, 2016
1 parent 2734a63 commit 147fa79
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"encoding/json"
"fmt"
"net"
"net/http"
"net/http/httputil"
Expand Down Expand Up @@ -97,6 +98,13 @@ func (s *Server) roleHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusNotFound)
return
}

vars := mux.Vars(r)
if role != vars["role"] {
http.Error(w, fmt.Sprintf("Invalid role %s", vars["role"]), http.StatusForbidden)
return
}

roleARN := s.iam.roleARN(role)
credentials, err := s.iam.assumeRole(roleARN, remoteIP)
if err != nil {
Expand Down

0 comments on commit 147fa79

Please sign in to comment.