user

package
v0.0.0-...-1679750 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthCode

type AuthCode int
const (
	DENY_ACCESS  AuthCode = 0
	USER_ACCESS  AuthCode = 1
	ADMIN_ACCESS AuthCode = 2
)

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(repo UserRepository) *Controller

func (*Controller) GetUsers

func (c *Controller) GetUsers() http.HandlerFunc

Returns a function that handles GET requests to /users

func (*Controller) RegisterRoutes

func (c *Controller) RegisterRoutes(router *chi.Mux)

func (*Controller) UserAuthenticationMiddleware

func (c *Controller) UserAuthenticationMiddleware(version string, exceptions []string) func(next http.Handler) http.Handler

Middleware which creates the users table if it doesn't exist, and then ensures the `X-Ms-Client-Principal-Id` header is present and check if the user is in the database

type User

type User struct {

	// An identifier for the caller set by the identity provider.
	PrincipalId string `json:"X-Ms-Client-Principal-Id"`

	// A human-readable name for the caller set by the identity provider.
	PrincipalName string `json:"X-Ms-Client-Principal-Name"`

	// The name of the identity provider used by App Service Authentication.
	PrincipalProvider string `json:"X-Ms-Client-Principal-Idp"`

	// Application Access Level
	AccessLevel AuthCode `json:"access_level"`
}

User represents a user in the database

type UserMSSQL

type UserMSSQL struct {
	// contains filtered or unexported fields
}

func (*UserMSSQL) GetUser

func (repo *UserMSSQL) GetUser(principalID string) (User, error)

func (*UserMSSQL) GetUsers

func (repo *UserMSSQL) GetUsers() ([]User, error)

func (*UserMSSQL) InsertUser

func (repo *UserMSSQL) InsertUser(user User) error

InsertUser inserts a new user into the database

type UserRepository

type UserRepository interface {
	InsertUser(User) error
	GetUsers() ([]User, error)
	GetUser(string) (User, error)
}

func NewRepository

func NewRepository(db *sql.DB) UserRepository

Jump to

Keyboard shortcuts

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