irisauth

package module
v0.0.0-...-d0194bf Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2017 License: MIT Imports: 8 Imported by: 0

README

iris-auth

Iris Framework middleware for HTTP basic authentication. Supports checking logins against bcrypt hashed passwords.

Usage

import (
    "github.com/kataras/iris"
    "github.com/kataras/iris/context"
    "github.com/danbovey/iris-auth"
)

func main() {
    app := iris.Default()

    username := // Get username from database
    password := // Get password from database
    authMiddleware := irisauth.New(irisauth.NewSimpleBasic(username, password))

    routes := app.Party("/", authMiddleware)
    {
        routes.Get("/", func(ctx context.Context) {
            ctx.writeString("Hello world")
        })
    }
}

Authors

Documentation

Overview

Package irisauth implements Basic authentication.

Index

Constants

This section is empty.

Variables

View Source
var BcryptCost = 10

See https://godoc.org/golang.org/x/crypto/bcrypt#pkg-constants for more details.

Functions

func New

func New(datastore datastore.Datastore) context.Handler

Basic returns a context.Handler that authenticates via Basic Auth. Writes an iris.StatusUnauthorized if authentication fails.

func NewSimpleBasic

func NewSimpleBasic(userId, hashedPassword string) *datastore.Simple

NewSimpleBasic returns *datastore.Simple built from userid, password.

func SecureCompare

func SecureCompare(given string, actual string) bool

SecureCompare performs a constant time compare of two strings to limit timing attacks.

Types

This section is empty.

Directories

Path Synopsis
Package datastore implements datastore (key, value pair) interface.
Package datastore implements datastore (key, value pair) interface.

Jump to

Keyboard shortcuts

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