You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In an attempt to better understand the NATs ecosystem, I wanted to programmatically verify the Chain of Trust between the operator, account, and user JWTs. I am using the code below, I am happy to open a PR if this is a valuable example
funcmain() {
resolverServer:="http://localhost:9090/jwt/v1"claims, _:=jwt.Decode(userJWT) // userJWT provided by userurl:=fmt.Sprintf("%s/accounts/%s", accountServer, claims.Claims().Issuer)
resp, _:=http.Get(url)
acctJWT, _:=ioutil.ReadAll(resp.Body)
resp.Body.Close()
url=fmt.Sprintf("%s/operator", accountServer)
resp, _=http.Get(url)
opJWT, _:=ioutil.ReadAll(resp.Body)
resp.Body.Close()
opc, _:=jwt.DecodeOperatorClaims(string(opJWT))
acct, _:=jwt.Decode(string(acctJWT))
aopc, _:=jwt.DecodeAccountClaims(string(acctJWT))
// Does account JWT issuer match operator public key and did the operator public key sign the account JWTifaopc.Issuer==opPub&&opc.DidSign(acct) { // opPub -> operator public which is const at top of filefmt.Println(aopc.DidSign(claims))
} else {
log.Fatal("chain of trust not valid")
}
log.Print("chain of trust verified")
}
The text was updated successfully, but these errors were encountered:
In an attempt to better understand the NATs ecosystem, I wanted to programmatically verify the Chain of Trust between the operator, account, and user JWTs. I am using the code below, I am happy to open a PR if this is a valuable example
The text was updated successfully, but these errors were encountered: