1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 18:37:05 +00:00

update all basicauth code reference

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-11-25 04:54:20 +02:00
parent afa1d89a23
commit ba30ef4de1
5 changed files with 14 additions and 20 deletions

View File

@@ -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)
}