Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
@@ -4,12 +4,11 @@ import (
|
||||
"context"
|
||||
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/controllers"
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/tools/logger"
|
||||
accounts "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/accounts/v1"
|
||||
"github.com/coreos/go-oidc/v3/oidc"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"google.golang.org/grpc"
|
||||
"golang.org/x/oauth2"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
@@ -25,54 +24,50 @@ type AccountsNoAuthServer struct {
|
||||
ctrl *controllers.AccountController
|
||||
}
|
||||
|
||||
// SignUp should create a new user and return JWT tokens so the sessions is active right after registration
|
||||
func (a *AccountsNoAuthServer) SignUp(ctx context.Context, in *accounts.SignUpRequest) (*empty.Empty, error) {
|
||||
log := logger.FromContext(ctx)
|
||||
data := &controllers.AccountData{
|
||||
Username: in.Data.GetName(),
|
||||
Password: in.Password.GetPassword(),
|
||||
Email: in.Data.GetEmail(),
|
||||
}
|
||||
|
||||
uuid, err := a.ctrl.Create(ctx, data)
|
||||
func (a *AccountsNoAuthServer) SignIn(ctx context.Context, in *accounts.SignInRequest) (*empty.Empty, error) {
|
||||
provider, err := oidc.NewProvider(ctx, "https://authentik.badhouseplants.net")
|
||||
if err != nil {
|
||||
log.Error(err, "Couldn't create a user")
|
||||
return nil, status.Error(codes.Aborted, "user can't be created")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accessToken, err := a.ctrl.GenerateAccessToken(uuid)
|
||||
// Configure an OpenID Connect aware OAuth2 client.
|
||||
oauth2Config := oauth2.Config{
|
||||
ClientID: "softplayer-localhost",
|
||||
ClientSecret: "pRpe3scGUE2jNH6t5rqI9R4OROeQHs4eO6ku957mYjDumKhQGX8QJcO0BMJ2FG4sUpvFrqccEqWgc3wKMp94tC8LyvTnkPF0Tg0CaldAEHuoQQdNKAzXVxwrHE6kNyBC",
|
||||
RedirectURL: "http://localhost:8080/#/auth/callback",
|
||||
|
||||
// Discovery returns the OAuth2 endpoints.
|
||||
Endpoint: provider.Endpoint(),
|
||||
|
||||
// "openid" is a required scope for OpenID Connect flows.
|
||||
Scopes: []string{oidc.ScopeOpenID, "profile", "email"},
|
||||
}
|
||||
verifier := provider.Verifier(&oidc.Config{ClientID: "softplayer-localhost"})
|
||||
|
||||
oauth2Token, err := oauth2Config.Exchange(ctx, in.Code)
|
||||
if err != nil {
|
||||
log.Error(err, "Couldn't generate an access token")
|
||||
return nil, status.Error(codes.Aborted, "Couldn't generate Access Token")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
refreshToken, err := a.ctrl.GenerateRefreshToken(ctx, uuid)
|
||||
// Extract the ID Token from OAuth2 token.
|
||||
rawIDToken, ok := oauth2Token.Extra("id_token").(string)
|
||||
if !ok {
|
||||
return nil, status.Error(codes.Unauthenticated, "Couldn't parse oauth token")
|
||||
}
|
||||
|
||||
// Parse and verify ID Token payload.
|
||||
idToken, err := verifier.Verify(ctx, rawIDToken)
|
||||
if err != nil {
|
||||
log.Error(err, "Couldn't generate a refresh token")
|
||||
return nil, status.Error(codes.Aborted, "Couldn't generate Access Token")
|
||||
return nil, status.Error(codes.Unauthenticated, "Couldn't verify oauth token")
|
||||
}
|
||||
|
||||
header := metadata.Pairs(
|
||||
"access-token", accessToken,
|
||||
"refreshToken", refreshToken,
|
||||
)
|
||||
|
||||
if err := grpc.SetHeader(ctx, header); err != nil {
|
||||
log.Error(err, "Couldn't set headers")
|
||||
return nil, status.Error(codes.Unknown, "Couldn't set headers")
|
||||
// Extract custom claims
|
||||
var claims struct {
|
||||
Email string `json:"email"`
|
||||
Verified bool `json:"email_verified"`
|
||||
}
|
||||
if err := idToken.Claims(&claims); err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
func (a *AccountsNoAuthServer) SignIn(ctx context.Context, in *accounts.SignInRequest) (*empty.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "Endpoint is not implemented")
|
||||
}
|
||||
|
||||
func (a *AccountsNoAuthServer) ResetPassword(ctx context.Context, in *accounts.ResetPasswordRequest) (*empty.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "Endpoint is not implemented")
|
||||
}
|
||||
|
||||
func (acc *AccountsNoAuthServer) NewPassword(ctx context.Context, in *accounts.NewPasswordRequest) (*empty.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "Endpoint is not implemented")
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/controllers"
|
||||
proto "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/applications/v1"
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
)
|
||||
|
||||
func NewApplicationsGrpcImpl(controller ctrl.Manager, log logr.Logger) *ApplicationServer {
|
||||
return &ApplicationServer{
|
||||
controller: controller,
|
||||
logInstance: log,
|
||||
}
|
||||
}
|
||||
|
||||
type ApplicationServer struct {
|
||||
proto.UnimplementedApplicationsServer
|
||||
controller ctrl.Manager
|
||||
logInstance logr.Logger
|
||||
}
|
||||
|
||||
// Create an environment
|
||||
func (app *ApplicationServer) Create(ctx context.Context, in *proto.CreateOptions) (*proto.ApplicationFull, error) {
|
||||
log := app.logInstance
|
||||
log.WithValues("user_id", in.GetOwnerId().GetUuid(), "environment_id", in.GetSpec().GetEnvironemntId(), "app_name", in.GetSpec().GetApplication())
|
||||
ctx = logr.NewContext(ctx, log)
|
||||
|
||||
data := &controllers.ApplicationData{
|
||||
Name: in.Metadata.Name,
|
||||
Application: in.Spec.Application,
|
||||
Version: in.Spec.Version,
|
||||
Environemnt: in.Spec.EnvironemntId,
|
||||
Config: in.Spec.Config,
|
||||
RawConfig: "",
|
||||
}
|
||||
|
||||
application := &controllers.Application{
|
||||
UserID: in.GetOwnerId().GetUuid(),
|
||||
Controller: app.controller,
|
||||
Data: data,
|
||||
Token: in.GetToken().GetToken(),
|
||||
}
|
||||
|
||||
err := application.Create(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.ApplicationFull{
|
||||
Metadata: in.GetMetadata(),
|
||||
Id: &proto.ApplicationId{
|
||||
Uuid: application.Data.UUID,
|
||||
},
|
||||
Spec: in.GetSpec(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (app *ApplicationServer) Delete(ctx context.Context, in *proto.DeleteOptions) (*empty.Empty, error) {
|
||||
log := app.logInstance
|
||||
log.WithValues("user_id", in.GetOwnerId().GetUuid(), "app_id", in.GetId().GetUuid())
|
||||
ctx = logr.NewContext(ctx, log)
|
||||
|
||||
data := &controllers.ApplicationData{
|
||||
Name: in.Metadata.Name,
|
||||
UUID: in.GetId().GetUuid(),
|
||||
}
|
||||
|
||||
application := &controllers.Application{
|
||||
UserID: in.GetOwnerId().GetUuid(),
|
||||
Controller: app.controller,
|
||||
Data: data,
|
||||
Token: in.GetToken().GetToken(),
|
||||
}
|
||||
|
||||
err := application.Delete(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/controllers"
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/email"
|
||||
proto_email "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/email/v1"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
)
|
||||
|
||||
type EmailServer struct {
|
||||
proto_email.UnimplementedEmailValidationServer
|
||||
emailConfig email.EmailConf
|
||||
controller ctrl.Manager
|
||||
// When dev mode is enabled, email won't be sent, instead the code will be returned in metadata
|
||||
devMode bool
|
||||
}
|
||||
|
||||
func InitEmailServer(controller ctrl.Manager, emailConfig *email.EmailConf, devMode bool) *EmailServer {
|
||||
return &EmailServer{
|
||||
controller: controller,
|
||||
emailConfig: *emailConfig,
|
||||
devMode: devMode,
|
||||
}
|
||||
}
|
||||
|
||||
// Send the validation code to email
|
||||
func (c *EmailServer) SendRequest(ctx context.Context, in *proto_email.RequestValidation) (*emptypb.Empty, error) {
|
||||
// Validation
|
||||
if len(in.GetUserId()) == 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "user id must not be empty")
|
||||
}
|
||||
|
||||
// Body
|
||||
emailSvc := controllers.EmailSvc{
|
||||
Data: controllers.EmailData{
|
||||
UserID: in.GetUserId(),
|
||||
},
|
||||
EmailConfig: c.emailConfig,
|
||||
Controller: c.controller,
|
||||
DevMode: c.devMode,
|
||||
}
|
||||
err := emailSvc.SendVerification(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if c.devMode {
|
||||
header := metadata.Pairs("code", emailSvc.Data.Code)
|
||||
if err := grpc.SendHeader(ctx, header); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
func (c *EmailServer) ValidateEmail(ctx context.Context, in *proto_email.ConfirmValidation) (*emptypb.Empty, error) {
|
||||
// Validation
|
||||
if len(in.GetUserId()) == 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "user id must not be empty")
|
||||
}
|
||||
if in.GetCode() == 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "code must not be empty")
|
||||
}
|
||||
|
||||
// Body
|
||||
emailSvc := controllers.EmailSvc{
|
||||
Data: controllers.EmailData{
|
||||
UserID: in.GetUserId(),
|
||||
Code: fmt.Sprintf("%d", in.GetCode()),
|
||||
},
|
||||
EmailConfig: c.emailConfig,
|
||||
Controller: c.controller,
|
||||
}
|
||||
err := emailSvc.ConfirmVerification(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
@@ -1,261 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/controllers"
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/providers/infra"
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/providers/kubernetes"
|
||||
proto "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/environments/v1"
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
)
|
||||
|
||||
func NewapiGrpcImpl(controller ctrl.Manager, log logr.Logger) *EnvironmentsServer {
|
||||
return &EnvironmentsServer{
|
||||
controller: controller,
|
||||
logInstance: log,
|
||||
}
|
||||
}
|
||||
|
||||
type EnvironmentsServer struct {
|
||||
proto.UnimplementedEnvironmentsServer
|
||||
controller ctrl.Manager
|
||||
logInstance logr.Logger
|
||||
}
|
||||
|
||||
// Create an environment
|
||||
func (e *EnvironmentsServer) Create(ctx context.Context, in *proto.CreateOptions) (*proto.EnvironmentFull, error) {
|
||||
log := e.logInstance
|
||||
log.WithValues("user_id", in.GetOwnerId().GetUuid())
|
||||
ctx = logr.NewContext(ctx, log)
|
||||
|
||||
provider, err := infra.GetProvider(in.GetSpec().GetProvider().String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k8s, err := kubernetes.GetKubernetes(in.GetSpec().GetKubernetes().String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
location, err := provider.GetServerLocation(in.GetSpec().GetServerLocation().String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
serverType, err := provider.GetServerType(in.Spec.ServerType.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data := &controllers.EnvironemntData{
|
||||
Name: in.GetMetadata().GetName(),
|
||||
Description: in.GetMetadata().GetDescription(),
|
||||
Provider: provider.GetProviderName(),
|
||||
Kubernetes: k8s.GetKubernetesName(),
|
||||
Location: location,
|
||||
ServerType: serverType,
|
||||
DiskSize: int(in.GetSpec().GetDiskSize()),
|
||||
}
|
||||
|
||||
environment := &controllers.Environemnt{
|
||||
UserID: in.GetOwnerId().GetUuid(),
|
||||
Config: ctrl.GetConfigOrDie(),
|
||||
Controller: e.controller,
|
||||
Data: data,
|
||||
Token: in.GetToken().GetToken(),
|
||||
}
|
||||
|
||||
err = environment.Create(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.EnvironmentFull{
|
||||
Metadata: in.GetMetadata(),
|
||||
Id: &proto.EnvironmentId{
|
||||
Uuid: environment.Data.UUID,
|
||||
},
|
||||
Spec: in.GetSpec(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (e *EnvironmentsServer) Update(ctx context.Context, in *proto.UpdateOptions) (*proto.EnvironmentFull, error) {
|
||||
log := e.logInstance
|
||||
log.WithValues("user_id", in.GetOwnerId().GetUuid())
|
||||
ctx = logr.NewContext(ctx, log)
|
||||
|
||||
provider, err := infra.GetProvider(in.GetSpec().GetProvider().String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k8s, err := kubernetes.GetKubernetes(in.GetSpec().GetKubernetes().String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
location, err := provider.GetServerLocation(in.GetSpec().GetServerLocation().String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
serverType, err := provider.GetServerType(in.Spec.ServerType.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data := &controllers.EnvironemntData{
|
||||
Name: in.GetMetadata().GetName(),
|
||||
UUID: in.GetId().GetUuid(),
|
||||
Description: in.GetMetadata().GetDescription(),
|
||||
Provider: provider.GetProviderName(),
|
||||
Kubernetes: k8s.GetKubernetesName(),
|
||||
Location: location,
|
||||
ServerType: serverType,
|
||||
DiskSize: int(in.GetSpec().GetDiskSize()),
|
||||
}
|
||||
|
||||
environment := &controllers.Environemnt{
|
||||
Config: ctrl.GetConfigOrDie(),
|
||||
UserID: in.GetOwnerId().GetUuid(),
|
||||
Controller: e.controller,
|
||||
Data: data,
|
||||
Token: in.GetToken().GetToken(),
|
||||
}
|
||||
|
||||
err = environment.Update(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &proto.EnvironmentFull{
|
||||
Metadata: in.GetMetadata(),
|
||||
Id: in.GetId(),
|
||||
Spec: in.GetSpec(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func (e *EnvironmentsServer) Delete(ctx context.Context, in *proto.DeleteOptions) (*empty.Empty, error) {
|
||||
log := e.logInstance
|
||||
log.WithValues("user_id", in.GetOwnerId().GetUuid())
|
||||
ctx = logr.NewContext(ctx, log)
|
||||
|
||||
data := &controllers.EnvironemntData{
|
||||
Name: in.GetMetadata().GetName(),
|
||||
UUID: in.GetId().GetUuid(),
|
||||
}
|
||||
|
||||
environment := &controllers.Environemnt{
|
||||
Config: ctrl.GetConfigOrDie(),
|
||||
UserID: in.GetOwnerId().GetUuid(),
|
||||
Controller: e.controller,
|
||||
Data: data,
|
||||
Token: in.GetToken().GetToken(),
|
||||
}
|
||||
err := environment.Delete(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (e *EnvironmentsServer) Get(ctx context.Context, in *proto.GetOptions) (*proto.EnvironmentFull, error) {
|
||||
log := e.logInstance
|
||||
log.WithValues("user_id", in.GetOwnerId().GetUuid())
|
||||
ctx = logr.NewContext(ctx, log)
|
||||
|
||||
data := &controllers.EnvironemntData{
|
||||
UUID: in.GetId().GetUuid(),
|
||||
}
|
||||
|
||||
environment := &controllers.Environemnt{
|
||||
Config: ctrl.GetConfigOrDie(),
|
||||
UserID: in.GetOwnerId().GetUuid(),
|
||||
Controller: e.controller,
|
||||
Data: data,
|
||||
Token: in.GetToken().GetToken(),
|
||||
}
|
||||
|
||||
if err := environment.Get(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
provider, err := infra.GetProvider(environment.Data.Provider)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k8s, err := kubernetes.GetKubernetes(environment.Data.Kubernetes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &proto.EnvironmentFull{
|
||||
Spec: &proto.EnvironmentSpec{
|
||||
Provider: proto.Provider(proto.Provider_value[provider.RawProviderName()]),
|
||||
Kubernetes: proto.Kubernetes(proto.Kubernetes_value[k8s.RawKubernetesName()]),
|
||||
ServerLocation: proto.Location(proto.Location_value[provider.RawServerLocation(environment.Data.Location)]),
|
||||
ServerType: proto.ServerType(proto.ServerType_value[provider.RawServerType(environment.Data.ServerType)]),
|
||||
DiskSize: int32(environment.Data.DiskSize),
|
||||
},
|
||||
Id: in.GetId(),
|
||||
Metadata: &proto.EnvironmentMetadata{
|
||||
Name: environment.Data.Name,
|
||||
Description: environment.Data.Description,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (e *EnvironmentsServer) List(in *proto.ListOptions, stream proto.Environments_ListServer) error {
|
||||
logInstance := e.logInstance
|
||||
log := logInstance.WithValues("user_id", in.GetOwnerId().GetUuid())
|
||||
ctx := logr.NewContext(stream.Context(), log)
|
||||
|
||||
environment := &controllers.Environemnt{
|
||||
Config: ctrl.GetConfigOrDie(),
|
||||
UserID: in.GetOwnerId().GetUuid(),
|
||||
Controller: e.controller,
|
||||
Token: in.GetToken().GetToken(),
|
||||
}
|
||||
|
||||
envs, err := environment.List(ctx, in.GetSearchString())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, env := range envs {
|
||||
provider, err := infra.GetProvider(env.Data.Provider)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
k8s, err := kubernetes.GetKubernetes(env.Data.Kubernetes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := stream.Send(&proto.EnvironmentFull{
|
||||
Metadata: &proto.EnvironmentMetadata{
|
||||
Name: env.Data.Name,
|
||||
Description: env.Data.Description,
|
||||
},
|
||||
Id: &proto.EnvironmentId{
|
||||
Uuid: env.Data.UUID,
|
||||
},
|
||||
Spec: &proto.EnvironmentSpec{
|
||||
Provider: proto.Provider(proto.Provider_value[provider.RawProviderName()]),
|
||||
Kubernetes: proto.Kubernetes(proto.Kubernetes_value[k8s.RawKubernetesName()]),
|
||||
ServerLocation: proto.Location(proto.Location_value[provider.RawServerLocation(env.Data.Location)]),
|
||||
ServerType: proto.ServerType(proto.ServerType_value[provider.RawServerType(env.Data.ServerType)]),
|
||||
DiskSize: int32(env.Data.DiskSize),
|
||||
},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
22
api/v1/test_auth.go
Normal file
22
api/v1/test_auth.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/tools/logger"
|
||||
test "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/test/v1"
|
||||
)
|
||||
|
||||
func NewTestAuthRPCImpl() *TestAuthServer {
|
||||
return &TestAuthServer{}
|
||||
}
|
||||
|
||||
type TestAuthServer struct {
|
||||
test.UnimplementedTestAuthServiceServer
|
||||
}
|
||||
|
||||
func (t *TestAuthServer) Pong(ctx context.Context, in *test.PongRequest) (*test.PongResponse, error) {
|
||||
log := logger.FromContext(ctx)
|
||||
log.Info("Pong")
|
||||
return &test.PongResponse{}, nil
|
||||
}
|
||||
22
api/v1/test_no_auth.go
Normal file
22
api/v1/test_no_auth.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/tools/logger"
|
||||
test "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/test/v1"
|
||||
)
|
||||
|
||||
func NewTestNoAuthRPCImpl() *TestNoAuthServer {
|
||||
return &TestNoAuthServer{}
|
||||
}
|
||||
|
||||
type TestNoAuthServer struct {
|
||||
test.UnimplementedTestNoAuthServiceServer
|
||||
}
|
||||
|
||||
func (t *TestNoAuthServer) Ping(ctx context.Context, in *test.PingRequest) (*test.PingResponse, error) {
|
||||
log := logger.FromContext(ctx)
|
||||
log.Info("Ping")
|
||||
return &test.PingResponse{}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user