auth

package
v0.0.0-...-a5dd66c Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Basic

func Basic(c gococ.Context, p *gococ.Params) (interface{}, gococ.Interrupt)

*

  • Perform authentication. *
  • Params:
  • - realm (string): The name of the realm. (Default: "web")
  • - datasource (string): The name of the datasource that should be used to authenticate.
  • This datasource must be an `auth.UserDatasource`. (Default: "auth.UserDatasource") *
  • Context:
  • - http.Request (*http.Request): The HTTP request. This is usually placed into the
  • context for you.
  • - http.ResponseWriter (http.ResponseWriter): The response. This is usually placed
  • into the context for you. *
  • Datasource:
  • - An auth.UserDatasource. By default, this will look for a datasource named
  • "auth.UserDatasource". This can be overridden by the `datasource` param. *
  • Returns:
  • - True if the user authenticated. If not, this will send a 401 and then stop
  • the current chain.

Types

type UserDatasource

type UserDatasource interface {
	AuthUser(username, password string) (bool, error)
}

Authenticate a username/password pair.

This expects a username and a password as strings. A boolean `true` indicates that the user has been authenticated. A `false` indicates that the user/password combo has failed to auth. This is not necessarily an error. An error should only be returned when an unexpected condition has obtained during authentication.

Jump to

Keyboard shortcuts

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