feat(be/fe): enable captcha (#69)

* feat(ui): enable captcha

* feat(server): enable captcha

* fix(ui): fix login pane layout

* fix(config): remove unused config and files

* fix(be/fe): clean up code

* chore(fe/be): clean up code
This commit is contained in:
Hexxa 2021-08-06 22:27:24 -05:00 committed by GitHub
parent 021e5090be
commit 1fcb2223a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 262 additions and 82 deletions

View file

@ -17,6 +17,9 @@ type UsersCfg struct {
CookieHttpOnly bool `json:"cookieHttpOnly" yaml:"cookieHttpOnly"`
MinUserNameLen int `json:"minUserNameLen" yaml:"minUserNameLen"`
MinPwdLen int `json:"minPwdLen" yaml:"minPwdLen"`
CaptchaWidth int `json:"captchaWidth" yaml:"captchaWidth"`
CaptchaHeight int `json:"captchaHeight" yaml:"captchaHeight"`
CaptchaEnabled bool `json:"captchaEnabled" yaml:"captchaEnabled"`
}
type Secrets struct {
@ -60,6 +63,9 @@ func DefaultConfig() (string, error) {
CookieHttpOnly: true,
MinUserNameLen: 4,
MinPwdLen: 6,
CaptchaWidth: 256,
CaptchaHeight: 60,
CaptchaEnabled: true,
},
Secrets: &Secrets{
TokenSecret: "",

View file

@ -189,6 +189,10 @@ func initHandlers(router *gin.Engine, cfg gocfg.ICfg, deps *depidx.Deps) (*gin.E
rolesAPI.DELETE("/", userHdrs.DelRole)
rolesAPI.GET("/list", userHdrs.ListRoles)
captchaAPI := v1.Group("/captchas")
captchaAPI.GET("/", userHdrs.GetCaptchaID)
captchaAPI.GET("/imgs", userHdrs.GetCaptchaImg)
filesAPI := v1.Group("/fs")
filesAPI.POST("/files", fileHdrs.Create)
filesAPI.DELETE("/files", fileHdrs.Delete)

View file

@ -18,7 +18,8 @@ func TestConcurrency(t *testing.T) {
"users": {
"enableAuth": true,
"minUserNameLen": 2,
"minPwdLen": 4
"minPwdLen": 4,
"captchaEnabled": false
},
"server": {
"debug": true

View file

@ -21,7 +21,8 @@ func TestFileHandlers(t *testing.T) {
"users": {
"enableAuth": true,
"minUserNameLen": 2,
"minPwdLen": 4
"minPwdLen": 4,
"captchaEnabled": false
},
"server": {
"debug": true

View file

@ -19,7 +19,8 @@ func TestUsersHandlers(t *testing.T) {
"users": {
"enableAuth": true,
"minUserNameLen": 2,
"minPwdLen": 4
"minPwdLen": 4,
"captchaEnabled": false
},
"server": {
"debug": true