Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aamirmousavi/logoinig
logoing is a simple example for login and generate secure token with jwt and gin packages and postgres as our database
https://github.com/aamirmousavi/logoinig
go golang jwt jwt-authentication jwt-token login login-system security
Last synced: 13 days ago
JSON representation
logoing is a simple example for login and generate secure token with jwt and gin packages and postgres as our database
- Host: GitHub
- URL: https://github.com/aamirmousavi/logoinig
- Owner: aamirmousavi
- Created: 2022-05-13T22:43:58.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-05-13T23:07:07.000Z (over 2 years ago)
- Last Synced: 2024-10-22T02:14:57.145Z (2 months ago)
- Topics: go, golang, jwt, jwt-authentication, jwt-token, login, login-system, security
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Logoing
logoing is a simple example for login and generate secure token with jwt and gin packages and postgres as our database.
in this project we are not using token with cookies it's just a simple example you can develop it yourself.
note: don't recive your toekn in query parameters of your users request.# Contents
- [Install](#install)
- [Requirements](#requirements)
- [Testing](#testing)# Install
```
git clone github.com/aamirmousavi/logoinig
```
```
cd logoinig
```
and run the app
```
go run cmd/main.go
```
also you can build and run the build# Requirements
Install and run posgres
you can change postgres dataSourceName in internal/services/database/postgredb/pgresdb.go line 18also you need to create a table with user as name and
```
id int
username text
password text
firstname text
lastname text
```
as our columns
and insert one or more rows to your table
# Testing
I created a user with 'aamirmousavi' as username and '85856969A' as password
we send the request
```
curl --location --request POST 'localhost:8080/login' \
--form 'username="aamirmousavi"' \
--form 'password="85856969A"'
```
out:
```
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VybmFtZSI6ImFhbWlybW91c2F2aSIsImV4cCI6MTY1MjQ4MzMwMH0.oE5qtBNzoOHOdG8NrjUbjQ4_I8dMuM9AGBHQbRD3jJs
```
now we check our token
```
curl --location --request GET 'localhost:8080/admin?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VybmFtZSI6ImFhbWlybW91c2F2aSIsImV4cCI6MTY1MjQ4MzMwMH0.oE5qtBNzoOHOdG8NrjUbjQ4_I8dMuM9AGBHQbRD3jJs'
```
out:
```
hello aamirmousavi.
```