produce less garbage

This commit is contained in:
Quaternions 2024-12-09 20:10:23 -08:00
parent e495a8423f
commit 576c3a187a
2 changed files with 6 additions and 8 deletions

View File

@ -10,6 +10,7 @@ import (
"net/http"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"git.itzana.me/strafesnet/go-grpc/auth"
)
func NewServeCommand() *cli.Command {
@ -84,7 +85,7 @@ func serve(ctx *cli.Context) error {
log.Fatal(err)
}
sec := service.SecurityHandler{
Client: conn,
Client: auth.NewAuthServiceClient(conn),
}
srv, err := api.NewServer(svc, sec, api.WithPathPrefix("/v1"))

View File

@ -5,7 +5,6 @@ import (
"context"
"git.itzana.me/strafesnet/maps-service/pkg/api"
"git.itzana.me/strafesnet/go-grpc/auth"
"google.golang.org/grpc"
)
var (
@ -40,7 +39,7 @@ func (usr UserInfo) IsSubmitter(submitter int64) bool{
}
type SecurityHandler struct {
Client *grpc.ClientConn
Client auth.AuthServiceClient
}
func (svc SecurityHandler) HandleCookieAuth(ctx context.Context, operationName api.OperationName, t api.CookieAuth) (context.Context, error){
@ -49,23 +48,21 @@ func (svc SecurityHandler) HandleCookieAuth(ctx context.Context, operationName a
return nil, ErrMissingSessionID
}
client := auth.NewAuthServiceClient(svc.Client)
session, err := client.GetSessionUser(ctx, &auth.IdMessage{
session, err := svc.Client.GetSessionUser(ctx, &auth.IdMessage{
SessionID: sessionId,
})
if err != nil{
return nil, err
}
role, err := client.GetGroupRole(ctx, &auth.IdMessage{
role, err := svc.Client.GetGroupRole(ctx, &auth.IdMessage{
SessionID: sessionId,
})
if err != nil{
return nil, err
}
validate, err := client.ValidateSession(ctx, &auth.IdMessage{
validate, err := svc.Client.ValidateSession(ctx, &auth.IdMessage{
SessionID: sessionId,
})
if err != nil{