| 1 |
// package main is a binary that will print out the MDS vars and check the token. |
| 2 |
package main |
| 3 |
|
| 4 |
import ( |
| 5 |
"fmt" |
| 6 |
"os" |
| 7 |
|
| 8 |
"github.com/golang-jwt/jwt/v4" |
| 9 |
) |
| 10 |
|
| 11 |
const tokendir = "/run/container_launcher/attestation_verifier_claims_token" |
| 12 |
|
| 13 |
func main() { |
| 14 |
fmt.Println("Workload running") |
| 15 |
fmt.Println("Workload args:", os.Args) |
| 16 |
fmt.Println("Workload env vars:") |
| 17 |
for _, e := range os.Environ() { |
| 18 |
fmt.Println(e) |
| 19 |
} |
| 20 |
|
| 21 |
filedata, err := os.ReadFile(tokendir) |
| 22 |
if err != nil { |
| 23 |
fmt.Println(err) |
| 24 |
return |
| 25 |
} |
| 26 |
|
| 27 |
token, _, err := new(jwt.Parser).ParseUnverified(string(filedata), jwt.MapClaims{}) |
| 28 |
if err != nil { |
| 29 |
fmt.Println(err) |
| 30 |
return |
| 31 |
} |
| 32 |
|
| 33 |
claims, ok := token.Claims.(jwt.MapClaims) |
| 34 |
if !ok { |
| 35 |
fmt.Println(err) |
| 36 |
return |
| 37 |
} |
| 38 |
fmt.Println("aud: ", claims["aud"]) |
| 39 |
fmt.Println("iss: ", claims["iss"]) |
| 40 |
fmt.Println("secboot: ", claims["secboot"]) |
| 41 |
fmt.Println("oemid: ", claims["oemid"]) |
| 42 |
fmt.Println("hwmodel: ", claims["hwmodel"]) |
| 43 |
fmt.Println("swname: ", claims["swname"]) |
| 44 |
|
| 45 |
fmt.Println("Token looks okay") |
| 46 |
} |