Skip to content

Commit

Permalink
Add --extra-security flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mabartosz committed Jul 16, 2018
1 parent 9c62efa commit a76a0e5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ Usage of ./build/bin/darwin/kube2iam:
--base-role-arn string Base role ARN
--debug Enable debug features
--default-role string Fallback role to use when annotation is not set
--extra-security Hide additional metadata URLs
--hide-user-data Hide the instance's user-data
--host-interface string Host interface for proxying AWS metadata (default "docker0")
--host-ip string IP address of host
Expand Down
1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func addFlags(s *server.Server, fs *pflag.FlagSet) {
fs.BoolVar(&s.Verbose, "verbose", false, "Verbose")
fs.BoolVar(&s.Version, "version", false, "Print the version and exits")
fs.BoolVar(&s.HideUserData, "hide-user-data", false, "Hide the instance's user-data")
fs.BoolVar(&s.ExtraSecurity, "extra-security", false, "Hide additional metadata URLs")
}

func main() {
Expand Down
14 changes: 14 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Server struct {
Verbose bool
Version bool
HideUserData bool
ExtraSecurity bool
iam *iam.Client
k8s *k8s.Client
roleMapper *mappings.RoleMapper
Expand Down Expand Up @@ -299,6 +300,19 @@ func (s *Server) Run(host, token, nodeName string, insecure bool) error {
r.Handle("/{version}/user-data", appHandler(s.emptyResponseHandler))
r.Handle("/{version}/user-data/{path:.*}", appHandler(s.emptyResponseHandler))
}
if(s.ExtraSecurity) {
// permit instance identity document, but not its signatures
r.Handle("/{version}/dynamic/instance-identity/document", appHandler(s.reverseProxyHandler))
r.Handle("/{version}/dynamic/instance-identity/{path:.+}", appHandler(s.emptyResponseHandler))
// hide public keys, disk configuration, security group & iam information
r.Handle("/{version}/meta-data/public-keys/{path:.*}", appHandler(s.emptyResponseHandler))
r.Handle("/{version}/meta-data/block-device-mapping/{path:.*}", appHandler(s.emptyResponseHandler))
r.Handle("/{version}/meta-data/network/{path:.*}", appHandler(s.emptyResponseHandler))
r.Handle("/{version}/meta-data/security-groups", appHandler(s.emptyResponseHandler))
r.Handle("/{version}/meta-data/security-groups/{path:.*}", appHandler(s.emptyResponseHandler))
r.Handle("/{version}/meta-data/iam/info", appHandler(s.emptyResponseHandler))
r.Handle("/{version}/meta-data/iam/info/{path:.*}", appHandler(s.emptyResponseHandler))
}
r.Handle("/{version}/meta-data/iam/security-credentials", appHandler(s.securityCredentialsHandler))
r.Handle("/{version}/meta-data/iam/security-credentials/", appHandler(s.securityCredentialsHandler))
r.Handle("/{version}/meta-data/iam/security-credentials/{role:.*}", appHandler(s.roleHandler))
Expand Down

0 comments on commit a76a0e5

Please sign in to comment.