diff --git a/_examples/dependency-injection/overview/web/middleware/basicauth.go b/_examples/dependency-injection/overview/web/middleware/basicauth.go index 5d61fc72..8cda6629 100644 --- a/_examples/dependency-injection/overview/web/middleware/basicauth.go +++ b/_examples/dependency-injection/overview/web/middleware/basicauth.go @@ -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", }) diff --git a/_examples/file-server/file-server/main.go b/_examples/file-server/file-server/main.go index f353adc2..200aa365 100644 --- a/_examples/file-server/file-server/main.go +++ b/_examples/file-server/file-server/main.go @@ -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) diff --git a/_examples/mvc/login/web/middleware/basicauth.go b/_examples/mvc/login/web/middleware/basicauth.go index eaf085ba..093bdb54 100644 --- a/_examples/mvc/login/web/middleware/basicauth.go +++ b/_examples/mvc/login/web/middleware/basicauth.go @@ -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", }) diff --git a/_examples/mvc/repository/web/middleware/basicauth.go b/_examples/mvc/repository/web/middleware/basicauth.go index 5d61fc72..8cda6629 100644 --- a/_examples/mvc/repository/web/middleware/basicauth.go +++ b/_examples/mvc/repository/web/middleware/basicauth.go @@ -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", }) diff --git a/_examples/testing/httptest/main.go b/_examples/testing/httptest/main.go index c86fc7fc..a2bb3101 100644 --- a/_examples/testing/httptest/main.go +++ b/_examples/testing/httptest/main.go @@ -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) }