Giter VIP home page Giter VIP logo

beego-jwt-mysql's Introduction

Beego + JWT + MySQL

A sample Golang project that shows you how to create your APIs with Beego, also JWT (Json Web Token) is implemented. In this project I used MySQL database to store Users data.

Installation & Running

You should first install Golang and register GOPATH in your System Environment Valriables, read more in https://golang.org/doc/install.

Then install Beego and Bee Tool, read more in https://beego.me/quickstart

You need to install some pakcages that are used in this project, install them with: (I imagine that you've installed Beego & Bee Tool)

  • go get -u github.com/astaxie/beego/orm (Beego ORM Helper)
  • go get -u github.com/go-sql-driver/mysql (MySQL Driver for Golang)
  • go get -u golang.org/x/crypto/bcrypt (Bcrypt helper to hash passwords)
  • go get -u github.com/gbrlsnchs/jwt (JWT Helper)
  • go get -u github.com/SermoDigital/jose (also JWT Helper but I just used rsa keys loader from that)

After preparing your environment, clone this repository in %GOPATH%\src\beego_jwt_mysql.

  • For signing Json-Web-Tokens I used RSA public/private key pair, you must create keys folder in the root of project and then create two private.txt and public.txt files. Then put your Private RSA key text in public.txt and put your Public RSA key text in private.txt.
    • You can create RSA key pair by this commands: (You must have installed openssl on your system)
      • Private Key: openssl genrsa -out private.txt 2048
      • Public Key: openssl rsa -in private.txt -pubout > public.txt

Then you can run the project by this command:

If you want Beego to generate API documentation automatically for you using Swagger definition you can use this command instead:

Use Postman or any other tool that you're comfortable with to test your API

Developer

LICENSE: MIT

You can use this project for any purpose.

But if you like it, Let me know :) - Star It or Just send me a message!

beego-jwt-mysql's People

Contributors

mehranabi avatar

Watchers

 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.