Code Monkey home page Code Monkey logo

golang-sample-api-jwt's Introduction

Issues MIT License LinkedIn


Logo

golang-sample-api-jwt

A sample golang api to test, learn and have reference for implementing stuff
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

I wanted to build a test golang application able to :

  • Connect to a mySQL database via gorm to store user data
  • Use the Gin Web Framework to serve API
  • Secure API via 2 JWT different token usage :
    • a short lived "access token" (1 hour ) to use the API
    • a long refresh JWT token (15 days ), only able to get new up-to-date access and refresh token
  • Document the API via the Swagger UI

(back to top)

Built With

  • Go
  • Gin
  • Swaggo generate from anotations Swagger UI pages

(back to top)

Getting Started

.

Prerequisites

  • go
  • a mySQL database, use the one provided in docker or edit the main.go file
    docker-compose up

Installation

Below is an example of how you can instruct your audience on installing and setting up your app. This template doesn't rely on any external dependencies or services.

  1. Clone the repo
    git clone https://github.com/vinpel/golang-sample-api-jwt.git
  2. Install dependencies and build the app
    go build .
  3. Start the app
    go run .

(back to top)

Usage

  swag init && go run .
  • Set the application in production mode (disable swagger endpoint)
    1. edit the main.go file
    2. add the following line before the routeur initilisation
gin.SetMode(gin.ReleaseMode)
  1. restart / build / install the app
   go build .

(back to top)

Roadmap

  • Add Gin Framework
  • Add API endpoint to create a new user
  • Add Swaggo annotations to generate swagger json/yaml file
  • Add API endpoint to grab JWT tokens using user information email/passwod
  • Add API endpoint to grab JWT tokens from a refresh token
  • Add API secure endpoint to test the secure API (ping)
  • Change password algorithm to Argon 2
  • Add secure API to change the password (stay connected for other / disconnect)
  • Manage configuration https://github.com/spf13/viper
  • Add tests with ovh-venom

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Vincent Pélisset - @g4spine

Project Link: https://github.com/vinpel/golang-sample-api-jwt

(back to top)

Acknowledgments

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!

(back to top)

golang-sample-api-jwt's People

Contributors

vinpel 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.