github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/composed-auth/tokens/make-tokens.sh (about)

     1  #! /bin/bash 
     2  
     3  # jti: ID
     4  # iss: Issuer
     5  # roles: custom claim
     6  #
     7  # Token for inventoryManager
     8  token='token-bearer-inventory-manager.jwt'
     9  echo \
    10  '{"jti": "fred", "iss": "example.com", "roles": [ "inventoryManager" ]}'|\
    11  jwt -key ../keys/apiKey.prv -alg RS256 -sign - > ${token}
    12  jwt -key ../keys/apiKey.pem -alg RS256 -verify ${token}
    13  jwt -show ${token}
    14  
    15  # Token for API Keys
    16  token='token-apikey-reseller.jwt'
    17  echo \
    18  '{"jti": "fred", "iss": "example.com", "roles": [ "reseller" ]}'|\
    19  jwt -key ../keys/apiKey.prv -alg RS256 -sign - > ${token}
    20  jwt -key ../keys/apiKey.pem -alg RS256 -verify ${token}
    21  jwt -show ${token}
    22  
    23  token='token-apikey-customer.jwt'
    24  echo \
    25  '{"jti": "ivan", "iss": "example.com", "roles": [ "customer" ]}'|\
    26  jwt -key ../keys/apiKey.prv -alg RS256 -sign - > ${token}
    27  jwt -key ../keys/apiKey.pem -alg RS256 -verify ${token}
    28  jwt -show ${token}