auth

module
v3.13.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT

README

auth

Authentification for apps in microservices.

Getting Started

You can use a simple login/password file for authentication.

Basic Login/Password

Write user's credentials with the following format :

[id]:[login]:[argon2id password],[id2]:[login2]:[argon2id password2]

You can generate argon2id password using go run ./cmd/argon/ "password".

The session can be kept in a cookie, enabled by setting the cookieSecret flag (COOKIE_SECRET). Without a secret, cookies are disabled: nothing is written and none is accepted.

The content of the cookie is encrypted and authenticated with AES-256-GCM, with a key derived from the secret. It can't be read or modified by the client, and the cookie name is bound to the content so it can't be replayed under another name. The secret must be at least 32 bytes long, otherwise cookies are disabled and an error is logged. Use 32 random bytes or more, for example openssl rand -base64 32. Changing the secret invalidates every existing cookie.

Cookies written by previous versions, which were signed but readable, are rejected: users have to authenticate again once. To inspect a cookie, run go run ./cmd/cookie, which asks for the cookie name, its value and the secret.

Build

In order to build the whole stuff, run the following command.

make

Password encrypter accepts one argument, the password, and output the argon2id one.

Directories

Path Synopsis
cmd
argon command
cookie command
example_db command
example_memory command
oauth command
pkg
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL