Skip to content
/ authlib Public

Plug and play authentication module for Kaphos projects

Notifications You must be signed in to change notification settings

kaphos/authlib

Repository files navigation

Kaphos Go Authlib Package

This package is intended for internal use for authentication backends.

To use, first initialise an object, passing in parameters for the configuration:

import github.com/kaphos/authlib

config := authlib.Config{
    KMSPath:        "auth.keys",
    DBPath:         "auth.db",
    IdleTimeout:    time.Hour,
    ForcedTimeout:  time.Hour * 24,
    RmbMeTimeout:   time.Hour * 24 * 180,
    HashIterations: 7,
    HashMemory:     48,
}
authObj := authlib.New(config)

Several functions are exported:

  • authObj.HashPassword - Given a password, return the hash using the preset parameters and algorithm.
  • authObj.AttemptLogin - When a user submits a login form, checks if valid and creates the appropriate cookies
  • authObj.CheckLogin - When a user attempts to access a protected endpoint, checks the user's cookies
  • authObj.Logout - When a user wants to log out from their current session
  • authObj.LogoutAll - When a user wants to log out from all sessions (removes 'Remember Me' sessions as well)

About

Plug and play authentication module for Kaphos projects

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages