Add stats reporter events listener, restore all events for http layer, rework authentication middleware and authenticator interface

This commit is contained in:
ErickSkrauch
2020-02-16 13:23:47 +03:00
parent db728451f8
commit 40c53ea0d9
12 changed files with 602 additions and 185 deletions

View File

@@ -8,7 +8,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/elyby/chrly/auth"
"github.com/elyby/chrly/bootstrap"
"github.com/elyby/chrly/db"
"github.com/elyby/chrly/http"
@@ -82,7 +81,7 @@ var serveCmd = &cobra.Command{
SkinsRepo: skinsRepo,
CapesRepo: capesRepo,
MojangTexturesProvider: mojangTexturesProvider,
Auth: &auth.JwtAuth{Key: []byte(viper.GetString("chrly.secret"))},
Authenticator: &http.JwtAuth{Key: []byte(viper.GetString("chrly.secret"))},
TexturesExtraParamName: viper.GetString("textures.extra_param_name"),
TexturesExtraParamValue: viper.GetString("textures.extra_param_value"),
}).CreateHandler()

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"log"
"github.com/elyby/chrly/auth"
"github.com/elyby/chrly/http"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -14,8 +14,8 @@ var tokenCmd = &cobra.Command{
Use: "token",
Short: "Creates a new token, which allows to interact with Chrly API",
Run: func(cmd *cobra.Command, args []string) {
jwtAuth := &auth.JwtAuth{Key: []byte(viper.GetString("chrly.secret"))}
token, err := jwtAuth.NewToken(auth.SkinScope)
jwtAuth := &http.JwtAuth{Key: []byte(viper.GetString("chrly.secret"))}
token, err := jwtAuth.NewToken(http.SkinScope)
if err != nil {
log.Fatalf("Unable to create new token. The error is %v\n", err)
}