auth

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: GPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

package auth provides easy to use authentication primitives for GondulAPI. While implementing this is trivial, this package provides primitives that can be embedded directly into your own structs. It comes with two different solutions: Either full embedding, or pre-made functions that you can just pass everything to.

The reason there are two options is to allow trivial embedding when your data type is a struct, but also use the same code if your data type is not (e.g.: if it's an array). The benefit of the latter is limited, but ensures all auth checking uses the same code.

This all uses gondulapi.Config.HTTPUser and HTTPPw so user/pass is configured in the config file for now. This is likely to be expanded upon in the future.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPrivate

func CheckPrivate(basepath string, element string, method string, user string, password string) error

func CheckReadPublic

func CheckReadPublic(basepath string, element string, method string, user string, password string) error

Types

type Private

type Private struct{}

Private enforces user/password for both read and write-operations.

func (*Private) Auth

func (dummy *Private) Auth(basepath string, element string, method string, user string, password string) error

Auth implements the gondulapi.Auther interface

type ReadPublic

type ReadPublic struct{}

ReadPublic is used to allow GET requests without passwords, but enforce (global) auth for all other requests. To use this, simply add *auth.ReadPublic to your object struct. (the struct is empty on purpose, it only exists for easy embedding)

func (*ReadPublic) Auth

func (dummy *ReadPublic) Auth(basepath string, element string, method string, user string, password string) error

Auth implements the gondulapi.Auther interface

Jump to

Keyboard shortcuts

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