createsession

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package createsession logs in: the password checked, a session made for the device.

Index

Constants

View Source
const Lifetime = 30 * 24 * time.Hour

Lifetime is how long a session lasts without use: each use starts it again (readtoken).

Variables

View Source
var ErrBadCredentials = domain.Unauthorized("wrong password")

Functions

func CheckPassword

func CheckPassword(ctx context.Context, db bun.IDB, pass string) error

CheckPassword checks the password, in the same time whether one is set or not: ErrBadCredentials either way. The OAuth consent checks it too, without a session.

func Process

func Process(ctx context.Context, db bun.IDB, input Input) *run

Types

type Input

type Input struct {
	Password string `json:"password"`
	// Token asks the token in the answer too, for a client without cookies (the CLI): the web keeps it HttpOnly.
	Token bool `json:"token,omitempty" binding:"optional"`
}

type Result

type Result struct {
	Token     string    `json:"token,omitempty" binding:"optional"`
	ExpiresAt time.Time `json:"expires_at"`
}

Result is the new session: the token goes to the client, and only there.

Jump to

Keyboard shortcuts

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