Rate limit login stuff

This commit is contained in:
bel
2019-10-22 02:12:27 +00:00
parent cc41444b21
commit 80017bb32b
3 changed files with 11 additions and 3 deletions

View File

@@ -4,6 +4,8 @@ import (
"local/oauth2/oauth2server/config"
"local/router"
"local/storage"
"golang.org/x/time/rate"
)
var wildcard = router.Wildcard
@@ -17,7 +19,8 @@ const (
type Server struct {
*router.Router
store storage.DB
store storage.DB
limiter *rate.Limiter
}
func New() *Server {
@@ -27,8 +30,9 @@ func New() *Server {
}
purgeIssuedCredentials(store)
return &Server{
Router: router.New(),
store: store,
Router: router.New(),
store: store,
limiter: rate.NewLimiter(1, 3),
}
}