Token authorization is ready for MVP
All checks were successful
ci/woodpecker/push/build Pipeline was successful

Signed-off-by: Nikolai Rodionov <iam@allanger.xyz>
This commit is contained in:
2026-05-15 14:51:21 +02:00
parent efe9042bdc
commit d954491893
10 changed files with 188 additions and 58 deletions

View File

@@ -67,7 +67,7 @@ func (cmd *Server) Run(ctx context.Context) error {
Addr: cmd.RedisHost,
})
authInterceptor := controllers.NewAuthController(
authController := controllers.NewAuthController(
[]byte(cmd.JWTSecret),
cmd.AccessTokenTTL,
cmd.RefrestTokenTTL,
@@ -79,14 +79,14 @@ func (cmd *Server) Run(ctx context.Context) error {
grpc_zap.UnaryServerInterceptor(logger.SetupLogger("info")),
// jwtVerifier.JWTAuthInterceptor,
selector.UnaryServerInterceptor(
auth.UnaryServerInterceptor(authInterceptor.AuthInterceptorFN),
auth.UnaryServerInterceptor(authController.AuthInterceptorFN),
selector.MatchFunc(selectorRequireAuth),
),
),
grpc.ChainStreamInterceptor(
grpc_zap.StreamServerInterceptor(logger.SetupLogger("info")),
selector.StreamServerInterceptor(
auth.StreamServerInterceptor(authInterceptor.AuthInterceptorFN),
auth.StreamServerInterceptor(authController.AuthInterceptorFN),
selector.MatchFunc(selectorRequireAuth),
),
),
@@ -113,11 +113,12 @@ func (cmd *Server) Run(ctx context.Context) error {
}
// Services that should be accessible for tokens should go here
accounts.RegisterAccountsServiceServer(grpcServer, v1.NewAccountServer(accountCtrl, authInterceptor))
accounts.RegisterAccountsServiceServer(grpcServer, v1.NewAccountServer(accountCtrl, authController))
test.RegisterTestServiceServer(grpcServer, v1.NewTestServer())
test.RegisterPublicTestServiceServer(grpcServer, v1.NewPublicTestServer())
tokens.RegisterTokensServiceServer(grpcServer, v1.NewTokensServer(tokenCtrl, authInterceptor))
accounts.RegisterPublicAccountsServiceServer(grpcServer, v1.NewPublicAccountServer(accountCtrl, authInterceptor))
tokens.RegisterTokensServiceServer(grpcServer, v1.NewTokensServer(tokenCtrl, authController))
tokens.RegisterPublicTokensServiceServer(grpcServer, v1.NewPublicTokensServer(tokenCtrl, authController))
accounts.RegisterPublicAccountsServiceServer(grpcServer, v1.NewPublicAccountServer(accountCtrl, authController))
info := grpcServer.GetServiceInfo()
tokenCtrl.SetGRPCInfo(info)