aboutsummaryrefslogtreecommitdiffstats
path: root/routers/routes
diff options
context:
space:
mode:
authorJonas Franz <info@jonasfranz.software>2018-05-19 16:12:37 +0200
committerLauris BH <lauris@nix.lv>2018-05-19 17:12:37 +0300
commit951309f76aab22e3742e8872bf0642fcea2570ae (patch)
tree041e43fcc393d0ca07e4e274b28c1938e6604780 /routers/routes
parentf933bcdfeef359d8d9592dc0cf0aea244963e23c (diff)
downloadgitea-951309f76aab22e3742e8872bf0642fcea2570ae.tar.gz
gitea-951309f76aab22e3742e8872bf0642fcea2570ae.zip
Add support for FIDO U2F (#3971)
* Add support for U2F Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add vendor library Add missing translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add U2F support for Firefox, Chrome (Android) by introducing a custom JS library Add U2F error handling Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add U2F login page to OAuth Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move U2F user settings to a separate file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for u2f model Renamed u2f table name Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by refactoring Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add U2F documentation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove not needed console.log-s Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add default values to app.ini.sample Add FIDO U2F to comparison Signed-off-by: Jonas Franz <info@jonasfranz.software>
Diffstat (limited to 'routers/routes')
-rw-r--r--routers/routes/routes.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/routers/routes/routes.go b/routers/routes/routes.go
index 07be6653a6..1585a0876d 100644
--- a/routers/routes/routes.go
+++ b/routers/routes/routes.go
@@ -5,6 +5,8 @@
package routes
import (
+ "encoding/gob"
+ "net/http"
"os"
"path"
"time"
@@ -37,12 +39,13 @@ import (
"github.com/go-macaron/i18n"
"github.com/go-macaron/session"
"github.com/go-macaron/toolbox"
+ "github.com/tstranex/u2f"
"gopkg.in/macaron.v1"
- "net/http"
)
// NewMacaron initializes Macaron instance.
func NewMacaron() *macaron.Macaron {
+ gob.Register(&u2f.Challenge{})
m := macaron.New()
if !setting.DisableRouterLog {
m.Use(macaron.Logger())
@@ -214,6 +217,12 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/scratch", user.TwoFactorScratch)
m.Post("/scratch", bindIgnErr(auth.TwoFactorScratchAuthForm{}), user.TwoFactorScratchPost)
})
+ m.Group("/u2f", func() {
+ m.Get("", user.U2F)
+ m.Get("/challenge", user.U2FChallenge)
+ m.Post("/sign", bindIgnErr(u2f.SignResponse{}), user.U2FSign)
+
+ })
}, reqSignOut)
m.Group("/user/settings", func() {
@@ -235,6 +244,11 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/enroll", userSetting.EnrollTwoFactor)
m.Post("/enroll", bindIgnErr(auth.TwoFactorAuthForm{}), userSetting.EnrollTwoFactorPost)
})
+ m.Group("/u2f", func() {
+ m.Post("/request_register", bindIgnErr(auth.U2FRegistrationForm{}), userSetting.U2FRegister)
+ m.Post("/register", bindIgnErr(u2f.RegisterResponse{}), userSetting.U2FRegisterPost)
+ m.Post("/delete", bindIgnErr(auth.U2FDeleteForm{}), userSetting.U2FDelete)
+ })
m.Group("/openid", func() {
m.Post("", bindIgnErr(auth.AddOpenIDForm{}), userSetting.OpenIDPost)
m.Post("/delete", userSetting.DeleteOpenID)