auth

package module
v0.0.0-...-d04ce0e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 8 Imported by: 5

README

  • Authentication

This module is a library that provides authentication session for Greek government's e-class platform

For example use, see login_test.go and session_test.go files

Documentation

Index

Constants

View Source
const TokenDuration = 25 * time.Minute

Session token's duration (5 minutes less actually)

Variables

View Source
var (
	ErrNoCredentials      = errors.New("credentials not provided")
	ErrInvalidCredentials = errors.New("invalid credentials")
)

Functions

func Login

func Login(
	ctx context.Context,
	domainURL string,
	creds Credentials,
	client *http.Client,
) (*http.Client, error)

Login function authenticates user to eclass and stores session to the client provided. After successful login, returns the http.Client.

func Session

func Session(
	ctx context.Context,
	domainURL string,
	creds Credentials,
	client *http.Client,
) (*http.Client, error)

Session function authenticates user to eclass, stores session to the client provided and ensures that session will not expire. Returns the http.Client to be used, in case no client was provided.

Types

type Credentials

type Credentials struct {
	Username string
	Password string
}

func (*Credentials) Clear

func (crd *Credentials) Clear()

Clear method empties both Username & Password fields

func (Credentials) PasswordEmpty

func (crd Credentials) PasswordEmpty() bool

PasswordEmpty method checks if Password is empty

func (Credentials) UsernameEmpty

func (crd Credentials) UsernameEmpty() bool

UsernameEmpty method checks if Username is empty

type ErrInvalidDomain

type ErrInvalidDomain struct {
	DomainURL string
}

func (*ErrInvalidDomain) Error

func (e *ErrInvalidDomain) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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