abcxyz / jvs

Apache License 2.0
8 stars 0 forks source link

feat: Added signing code to JVS #19

Closed raserva closed 2 years ago

raserva commented 2 years ago

Built:

./scripts/build.sh justification; gcloud run deploy $APP_NAME --image=us-docker.pkg.dev/$APP_PROJECT/images/$APP_NAME:init --region=us-west1 --project=${APP_PROJECT} --platform=managed --set-env-vars="JVS_KEY=projects/<my_proj>/locations/global/keyRings/test-ring/cryptoKeys/test-key"

tested:

rsrv@rsrv-desktop:~/gopath/src/google-on-gcp/jvs$ grpcurl -proto protos/v0/jvs_service.proto     -H "Authorization: Bearer $(gcloud auth print-identity-token )"      -d '{"justifications": [{"category": "explanation", "value": "this is a test"}], "ttl": "3600s"}'      -max-msg-sz 9999999999      <my_url>:443       jvs.JVSService/CreateJustification
{
  "token": "<Token_String>"
}

Decoded:

{
  "aud": "TODO",
  "exp": 1651182213,
  "jti": "77e258fc-3d77-42ba-82bc-4d59958f694a",
  "iat": 1651178613,
  "iss": "jvs-service",
  "nbf": 1651178613,
  "sub": "TODO",
  "Justifications": [
    {
      "category": "explanation",
      "value": "this is a test"
    }
  ]
}