GithubHelp home page GithubHelp logo

luk4z7 / middleware-jwt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brainattica/golang-jwt-authentication-api-sample

3.0 3.0 0.0 61 KB

Middleware JWT (Json Web Token)

License: BSD 3-Clause "New" or "Revised" License

Go 88.35% Shell 11.65%
middleware golang api jwt docker

middleware-jwt's Introduction

Middleware JWT

Getting started

Clone the repository in folder do you prefer

cd /var/www
git clone https://github.com/luk4z7/middleware-jwt

Execute the file init.sh for up the docker containers

https://github.com/luk4z7/middleware-jwt for the canonical source repository
Middleware-jwt


 __  __ _     _     _ _                                   _          _
|  \/  (_) __| | __| | | _____      ____ _ _ __ ___      (_)_      _| |_
| |\/| | |/ _` |/ _` | |/ _ \ \ /\ / / _` | '__/ _ \_____| \ \ /\ / / __|
| |  | | | (_| | (_| | |  __/\ V  V / (_| | | |  __/_____| |\ V  V /| |_
|_|  |_|_|\__,_|\__,_|_|\___| \_/\_/ \__,_|_|  \___|    _/ | \_/\_/  \__|
                                                       |__/
DOCKER
Generate new containers ? [ 1 ]
Delete all containers ?   [ 2 ]
Start new build ?         [ 3 ]

Test api /test/hello receive 401 Unauthorized

➜  middleware-jwt (master) ✗ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://127.0.0.1:6060/test/hello

HTTP/1.1 401 Unauthorized
Date: Sat, 11 Feb 2017 12:53:45 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8

Get token

➜  middleware-jwt (master) ✗ curl -H "Content-Type: application/json" -X POST -d '{"Username":"root", "Password":"12345"}' http://127.0.0.1:6060/token-auth
{"token":"eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODcwNzcwNTksImlhdCI6MTQ4NjgxNzg1OSwic3ViIjoiIn0.omoQv8ViTOI--QI3TQB4VAdhOLtyKman_fUnG7Hf5EQx4AhNJDgGBmSEOsCMZokE4AHSxAIYFmhFQ6oW2XZQDSJM7jqpn9Mi2TmtKiWnOcU4bRNwYcI8wjFyoWcxQW8M8sPJ9h3MpAnRaZQ1Z3hippK8PjAuujtQfnNUNqdOPuqRpK_r48fiC2BRz5Z18_DBjS9Xl7ZZOTtBxHRA-BNcnSLzzoMCE9VJ83oEs2Q29aBGUW4Ghfz-k8eDHlI1q6l7dvs4Yz_pHAim0__m0do9j8hAHMrWahb2eVLO19kmug6V3Rd2JFY3qLNh0MNW7DHLbwnZ7n7mjXy5KyKGqK07Gg"}

Access the route test/hello with authorization

➜  middleware-jwt (master) ✗ curl -H "Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODY5NTgwMjMsImlhdCI6MTQ4NjY5ODgyMywic3ViIjoiIn0.nUgmyKnVUGOLpzBNpCiV5B13oRVfunZi-5tmkDFizbfwKhIVi_2oysZeRwozZQJYSLkVrU8iVAoUxUfh43-1MhL2tUei_SyOiAnwBmCq1KIBzo0yznQQylg_zUptHEJFzofqNPNyr_NS60VJTCGW-FVElSX-k-ecTlOXmFLE-Geg4MAn1_wxnIJpRrLha3httMckk1zTkVkc6sWZVlQlfbS81e9xYWvrjF88xo3pb9XdBc4KWCfRT4Nz3pNMNdTcEWWvVC2Xk9DdWbTIXr0PH4AivDiIPeBh331wB04dduc9_ufXnal3TlS2ZnUm0jYJRaFPaDbacWpxERr402L8mw" http://127.0.0.1:6060/test/hello

Hello, World!

middleware-jwt's People

Contributors

luk4z7 avatar raul-diffindo avatar

Stargazers

 avatar  avatar Robert avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.