mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
update all basicauth code reference
This commit is contained in:
parent
afa1d89a23
commit
ba30ef4de1
|
@ -5,8 +5,6 @@ package middleware
|
|||
import "github.com/kataras/iris/v12/middleware/basicauth"
|
||||
|
||||
// BasicAuth middleware sample.
|
||||
var BasicAuth = basicauth.New(basicauth.Config{
|
||||
Users: map[string]string{
|
||||
"admin": "password",
|
||||
},
|
||||
var BasicAuth = basicauth.Default(map[string]string{
|
||||
"admin": "password",
|
||||
})
|
||||
|
|
|
@ -74,10 +74,8 @@ func main() {
|
|||
}),
|
||||
})
|
||||
|
||||
auth := basicauth.New(basicauth.Config{
|
||||
Users: map[string]string{
|
||||
"myusername": "mypassword",
|
||||
},
|
||||
auth := basicauth.Default(map[string]string{
|
||||
"myusername": "mypassword",
|
||||
})
|
||||
|
||||
filesRouter.Delete("/{file:path}", auth, deleteFile)
|
||||
|
|
|
@ -5,8 +5,6 @@ package middleware
|
|||
import "github.com/kataras/iris/v12/middleware/basicauth"
|
||||
|
||||
// BasicAuth middleware sample.
|
||||
var BasicAuth = basicauth.New(basicauth.Config{
|
||||
Users: map[string]string{
|
||||
"admin": "password",
|
||||
},
|
||||
var BasicAuth = basicauth.Default(map[string]string{
|
||||
"admin": "password",
|
||||
})
|
||||
|
|
|
@ -5,8 +5,6 @@ package middleware
|
|||
import "github.com/kataras/iris/v12/middleware/basicauth"
|
||||
|
||||
// BasicAuth middleware sample.
|
||||
var BasicAuth = basicauth.New(basicauth.Config{
|
||||
Users: map[string]string{
|
||||
"admin": "password",
|
||||
},
|
||||
var BasicAuth = basicauth.Default(map[string]string{
|
||||
"admin": "password",
|
||||
})
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
func newApp() *iris.Application {
|
||||
app := iris.New()
|
||||
|
||||
authConfig := basicauth.Config{
|
||||
Users: map[string]string{"myusername": "mypassword"},
|
||||
opts := basicauth.Options{
|
||||
Allow: basicauth.AllowUsers(map[string]string{"myusername": "mypassword"}),
|
||||
}
|
||||
|
||||
authentication := basicauth.New(authConfig)
|
||||
authentication := basicauth.New(opts) // or just: basicauth.Default(map...)
|
||||
|
||||
app.Get("/", func(ctx iris.Context) { ctx.Redirect("/admin") })
|
||||
|
||||
|
@ -36,7 +36,9 @@ func h(ctx iris.Context) {
|
|||
username, password, _ := ctx.Request().BasicAuth()
|
||||
// third parameter it will be always true because the middleware
|
||||
// makes sure for that, otherwise this handler will not be executed.
|
||||
|
||||
// OR:
|
||||
// ctx.User().GetUsername()
|
||||
// ctx.User().GetPassword()
|
||||
ctx.Writef("%s %s:%s", ctx.Path(), username, password)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user