{
  "servicename": "keymgr",
  "routes": [
    {
      "route": "/clients/:clientid",
      "configured": true,
      "type": "get",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteGetClientFromClientid",
      "description": "Get client info from clientid1",
      "paramschema": {
        "required": [
          "clientid"
        ],
        "type": "object",
        "properties": {
          "clientid": {
            "description": "the clientid",
            "type": [
              "integer",
              "string"
            ]
          }
        }
      },
      "examples": [
        {
          "param": "/clients/1"
        },
        {
          "param": "/clients/a1"
        }
      ]
    },
    {
      "route": "/clients/:clientid",
      "configured": true,
      "type": "put",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteAllocateAccessKeys",
      "description": "Allocate Keys for a client identified by clientid",
      "paramschema": {
        "required": [
          "clientid"
        ],
        "type": "object",
        "properties": {
          "clientid": {
            "description": "the clientid",
            "type": "integer"
          }
        }
      },
      "examples": [
        {
          "param": "/clients/1"
        }
      ]
    },
    {
      "route": "/clients/:clientid",
      "configured": true,
      "type": "delete",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteRevokeClient",
      "description": "Delete a client identified by clientid",
      "paramschema": {
        "required": [
          "clientid"
        ],
        "type": "object",
        "properties": {
          "clientid": {
            "description": "the clientid",
            "type": "integer"
          }
        }
      },
      "examples": [
        {
          "param": "/clients/1"
        }
      ]
    },
    {
      "route": "/acckeys/:acckey/",
      "configured": true,
      "type": "get",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteGetClientFromAcckey",
      "description": "Get client info from acckey",
      "paramschema": {
        "required": [
          "acckey"
        ],
        "type": "object",
        "properties": {
          "acckey": {
            "description": "access key of the client",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/acckeys/<acckeyvalue>"
        }
      ]
    },
    {
      "route": "/grants/check",
      "configured": true,
      "type": "post",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteCheckAccessOneService",
      "description": "Authenticate and Check acckey has access to the service",
      "bodyschema": {
        "required": [
          "headers",
          "servicename"
        ],
        "type": "object",
        "properties": {
          "headers": {
            "description": "headers",
            "type": "object",
            "required": [
              "authorization"
            ],
            "properties": {
              "authroization": {
                "type": "string",
                "description": "auth header basic or hmac"
              },
              "date": {
                "type": "string"
              }
            }
          },
          "servicename": {
            "description": "The service name",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/grants/check",
          "payload": {
            "headers": {
              "authorization": "auth header basic or hmac",
              "date": "date"
            },
            "servicename": "sampleserviceacckey"
          }
        }
      ]
    },
    {
      "route": "/grants/checkjwt",
      "configured": true,
      "type": "post",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteCheckJWTAccessOneService",
      "description": "Check JWT to see if the service has access to the service, if servicename is not given it expects to just decode the token and return.",
      "bodyschema": {
        "required": [
          "headers"
        ],
        "type": "object",
        "properties": {
          "headers": {
            "description": "headers",
            "type": "object",
            "required": [
              "authorization"
            ],
            "properties": {
              "authroization": {
                "type": "string",
                "description": "auth header bearer with jwt"
              }
            }
          },
          "servicename": {
            "description": "the name of the service",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/grants/checkjwt",
          "payload": {
            "headers": {
              "authorization": "auth header bearer with jwt"
            },
            "servicename": "sampleservicejwt"
          }
        }
      ]
    },
    {
      "route": "/grants/:servicename/acckeys/:acckey/",
      "configured": true,
      "type": "get",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteGetAccessOneService",
      "description": "Check acckey has access to the service",
      "paramschema": {
        "required": [
          "servicename",
          "acckey"
        ],
        "type": "object",
        "properties": {
          "servicename": {
            "description": "the name of the service",
            "type": "string"
          },
          "acckey": {
            "description": "the acckey",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/grants/machineconfig/acckeys/<acckeyvalue>"
        }
      ]
    },
    {
      "route": "/grants/:servicename/acckeys/:acckey/",
      "configured": true,
      "type": "post",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteGrantAccess",
      "description": "Grant access to service for acckey",
      "paramschema": {
        "required": [
          "servicename",
          "acckey"
        ],
        "type": "object",
        "properties": {
          "servicename": {
            "description": "the name of the service to grant access to",
            "type": "string"
          },
          "acckey": {
            "description": "the acckey",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/grants/machineconfig/acckeys/acckeyvalue"
        }
      ]
    },
    {
      "route": "/grants/:servicename/acckeys/:acckey/",
      "configured": true,
      "type": "delete",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteRevokeAccess",
      "description": "Revoke access to service for acckey",
      "paramschema": {
        "required": [
          "servicename",
          "acckey"
        ],
        "type": "object",
        "properties": {
          "servicename": {
            "description": "the name of the service to grant access to",
            "type": "string"
          },
          "acckey": {
            "description": "the acckey",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/grants/machineconfig/acckeys/acckeyvalue"
        }
      ]
    },
    {
      "route": "/grants/acckeys/:acckey/",
      "configured": true,
      "type": "get",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteGetAccessServices",
      "description": "Get services acckey has access to",
      "paramschema": {
        "required": [
          "acckey"
        ],
        "type": "object",
        "properties": {
          "acckey": {
            "description": "the acckey",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/grants/acckeys/acckeyvalue"
        }
      ]
    },
    {
      "route": "/acckeys/:acckey/jwt",
      "configured": true,
      "type": "post",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RoutePostJWT",
      "description": "Create JWT given acckey and secret. Use normal route to create access key and secret key for a given client id. Then you can use these to procure the Json Web Token. Pass the token in http header as 'Authorization: Bearer <token>' when using curl or postman or use the test framework to pass the token",
      "paramschema": {
        "required": [
          "acckey"
        ],
        "type": "object",
        "properties": {
          "acckey": {
            "description": "the acckey",
            "type": "string"
          }
        }
      },
      "bodyschema": {
        "required": [
          "secretkey"
        ],
        "type": "object",
        "properties": {
          "secretkey": {
            "description": "Secret key for authentication, corresponding to the acckey",
            "type": "string"
          },
          "secret": {
            "description": "Secret to sign the JWT with",
            "type": "string"
          },
          "expires": {
            "description": "expiry of this jwt in seconds, default is 3600 secs (1 hour)",
            "type": "integer",
            "minimum": 60,
            "maximum": 2592000
          },
          "sub": {
            "description": "subject matter for this JWT",
            "type": "string"
          },
          "claims": {
            "type": "object",
            "properties": {
              "services": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "scope": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "examples": [
        {
          "param": "/acckeys/acckeyvalue/jwt",
          "payload": {
            "secretkey": "secretkey",
            "secret": "helloworld",
            "expires": 600,
            "sub": "TestofJWT",
            "claims": {
              "services": [
                "sampleservicejwt"
              ],
              "scope": [
                "read:foo",
                "write:bar"
              ]
            }
          }
        },
        {
          "param": "/acckeys/acckeyvalue/jwt",
          "payload": {
            "secretkey": "secretkey",
            "expires": 600,
            "sub": "TestofJWT"
          }
        }
      ]
    },
    {
      "route": "/jwts/:jwt",
      "configured": true,
      "type": "get",
      "routeclass": "./apikeymgr.js",
      "routefunction": "RouteVerifyJWT",
      "description": "Verify JWT and return the payload",
      "paramschema": {
        "required": [
          "jwt"
        ],
        "type": "object",
        "properties": {
          "jwt": {
            "description": "JWT token value",
            "type": "string"
          },
          "secret": {
            "description": "Optiommal query parameter secret to sign the JWT with",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/jwts/jwtoken?secret=helloworld"
        },
        {
          "param": "/jwts/jwtoken"
        }
      ]
    }
  ],
  "loglevel": "trace"
}