httpguard

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go-HTTPGuard

Prepare:

git clone git@gitlab.com:Laisky/configs.git /opt/config

Run:

go run entrypoints/main.go --config=/etc/go-httpguard/settings --debug --dry

Settings.yml:

addr: "0.0.0.0:24215"
audit: "http://xxx/httpguard/logs"
backend: "http://xxx"
secret: "123456"
users:
  - username: "readonly"
    password: "readonly"
    permissions:
      get:
        - "/"
      head:
        - "/"
  - username: "laisky"
    permissions:
      get:
        - "/"
      head:
        - "/"
      post:
        - "/"

token:

{
  "exp": 4701978061,
  "uid": "jiudian-ai"
}

Each request should has the Cookie named token:

demo

You can try with readonly token:

eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjQ3MDE5NzgwNjEsInVpZCI6InJlYWRvbmx5In0.PRDnh3tpfxd2G4TDj29HW3QA5dZKq068AYaLSTpA2LQFuAZD-luXvorUfvIXGKY1ESkHVPbkvWEZaX7tTh2E8w

(You can generate HS512 token at https://jwt.io/)

generate

Documentation

Index

Constants

View Source
const (
	Username  = "username"
	ExpiresAt = "expires_at"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Audit

type Audit struct{}

func NewAudit

func NewAudit() *Audit

func (*Audit) Entrypoint

func (a *Audit) Entrypoint(c *chaining.Chain) (interface{}, error)

func (*Audit) PushAuditRecord

func (a *Audit) PushAuditRecord(data map[string]interface{})

type Auth

type Auth struct {
	*utils.JWT
}

func NewAuth

func NewAuth(secret string) *Auth

func (*Auth) Entrypoint

func (a *Auth) Entrypoint(c *chaining.Chain) (interface{}, error)

type Backend

type Backend struct{}

func NewBackend

func NewBackend() *Backend

func (*Backend) Entrypoint

func (b *Backend) Entrypoint(c *chaining.Chain) (ret interface{}, err error)

func (*Backend) RequestBackend

func (b *Backend) RequestBackend(ctx *fasthttp.RequestCtx, url string) (err error)

RequestBackend request backend by internal http client

type Controllor

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

func NewController

func NewController(middlewares ...Middleware) *Controllor

func (*Controllor) MiddlewareChain

func (co *Controllor) MiddlewareChain(c *chaining.Chain) *chaining.Chain

func (*Controllor) Run

func (c *Controllor) Run() (err error)

type CtxMeta

type CtxMeta struct {
	Ctx  *fasthttp.RequestCtx
	Meta map[string]interface{}
}

type Middleware

type Middleware interface {
	Entrypoint(c *chaining.Chain) (interface{}, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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