api

command
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2020 License: BSD-3-Clause Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Gateway with a JWT

This recipe is a gateway with a service protected by a JWT.

Installation

  • Install Go
git clone https://github.com/project-flogo/microgateway
cd microgateway/activity/jwt/examples/api

Testing

Generate a JWT token using the below information: (You may use http://jwtbuilder.jamiekurtz.com/)

{
     "issuer": "Mashling",
     "audience": "www.mashling.io",
     "subject": "tempuser@mail.com",
     "id": "XX",
     "signingMethod": "HMAC"
}
{
     "key": "qwertyuiopasdfghjklzxcvbnm789101"
}

Note: The id in the above payload is the pet Id.

Start the gateway:

go run main.go

and test below scenario.

Token is Valid

Now run the following in a new terminal:

curl --request GET http://localhost:9096/pets -H "Authorization: Bearer <Access_Token>"

You should see the following response:

{
   "error":"JWT token is valid",
   "pet":{
      "category":{
         "id":0,
         "name":"string"
      },
      "id":4,
      "name":"gigigi",
      "photoUrls":[
         "string"
      ],
      "status":"available",
      "tags":[
         {
            "id":0,
            "name":"string"
         }
      ]
   }
}
Token Invalid

You should see the following response:

{
   "error":{
      "error":false,
      "errorMessage":"",
      "token":{
         "claims":null,
         "signature":"",
         "signingMethod":"",
         "header":null
      },
      "valid":false,
      "validationMessage":"signature is invalid"
   },
   "pet":null
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL