Categorygithub.com/grqphical07/Authentication-API
modulepackage
1.0.0
Repository: https://github.com/grqphical07/authentication-api.git
Documentation: pkg.go.dev

# README

Authentication API

API Tests

A simple Authentication REST API made with Go, SQLite and Gin.

It works by having a Refresh JSON Web Token and an Access JSON Web Token. The access token allows you access to autheticated parts of the site whilst the refresh token allows you to get a new access token if the one you have expires

The backend just uses an SQLite database to store account credentials

# Functions

Used to check if the incoming request has an authentication token and if it's valid If it is valid, it will continue the request normally, otherwise it will return either a 400 for a request missing a token or a 401 if the token is not valid.
Creates an access JWT token from an Account object Returns the token and nil on a successful encoding Otherwise it returns a blank string and an error.
Handles account creation.
No description provided by the author
No description provided by the author
Used to convert an error to a string.
Generates the JSON for an HTTP error.
No description provided by the author
Takes in a password and generates a hash from it If it hashes successfully, it returns the hash and nil.
Basic API route to test the authentication with.
Loads env variables in .env so they can be retrieved with os.Getenv().
Handles logging into existing accounts.
No description provided by the author
API Route to get a new access token if the current one is expired.
Takes in an access JWT, verifies the signature and returns the username associated with the account that is authenticated Returns either the username and nil or a blank string and an error if it failed to authenticate it.
No description provided by the author
Ensures passwords are valid meaning they are in between 8 and 70 characters, have at least one capital, one number and one special character Example valid password: Password123! Returns nil if the username is valid and returns an error if it isnt'.
No description provided by the author
Ensures that the given username matches the username requirements All usernames must be shorter than 24 characters Returns nil if the username is valid and returns an error if it isnt'.
Verifies if a password and hash match If they match return true, otherwise return false.

# Constants

No description provided by the author

# Structs

Used to represent an account in the application.
No description provided by the author