项目作者: gobuffalo

项目描述 :
Buffalo Basic Auth Middleware
高级语言: Go
项目地址: git://github.com/gobuffalo/mw-basicauth.git
创建时间: 2018-07-30T12:06:00Z
项目社区:https://github.com/gobuffalo/mw-basicauth

开源协议:MIT License

下载


mw-basicauth

Standard Test
Go Reference
Go Report Card

Basic HTTP Authentication Middleware
for Buffalo

Installation

  1. $ go get github.com/gobuffalo/mw-basicauth

Usage

  1. auth := func(c buffalo.Context, u, p string) (bool, error) {
  2. return (u == "username" && p == "password"), nil
  3. }
  4. app.Use(basicauth.Middleware(auth))

Hitting protected endpoints

  1. Base64 Encode username:password, which becomes dXNlcm5hbWU6cGFzc3dvcmQK in the aforementioned example

  2. Then pass the following HTTP header along with all requests to protected endpoints: Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQK