Adding Live 2fa capacity

* Some requests may be sensitive enough to require a secondary
two-factor authorization on the spot
* Examples: changing password, changing email address, viewing API
tokens etc
* This creates a core handler that can attach to any Auth-able method
which will require a "twofactorcode" query param before processing
This commit is contained in:
🐙PiperYxzzy
2022-05-01 22:34:07 +02:00
parent 67efb0600f
commit dbdd4cb650
4 changed files with 98 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ import (
func Migrate(g *gorm.DB) {
g.AutoMigrate(&models.User{})
g.AutoMigrate(&models.Admin{})
g.AutoMigrate(&models.TotpUsage{})
}
func main() {
@@ -36,6 +37,7 @@ func main() {
v1Sec := v1.Group("/sec", core.UserAuth())
v1Sec.GET("/doot", core.Doot())
v1Sec.GET("/2fa-doot", core.LiveTwoFactor(), core.Doot())
// Administrative login
v1.POST("/admin", core.AdminLogin())