1
0
forked from extern/smegmesh
smegmesh/pkg/middleware/auth.go
2023-10-24 00:12:38 +01:00

30 lines
759 B
Go

package middleware
import (
"context"
"errors"
logging "github.com/tim-beatham/wgmesh/pkg/log"
"github.com/tim-beatham/wgmesh/pkg/rpc"
)
// AuthRpcProvider implements the AuthRpcProvider service
type AuthRpcProvider struct {
rpc.UnimplementedAuthenticationServer
}
// JoinMesh handles a JoinMeshRequest. Succeeds by stating the node managed to join the mesh
// or returns an error if it failed
func (a *AuthRpcProvider) JoinMesh(ctx context.Context, in *rpc.JoinAuthMeshRequest) (*rpc.JoinAuthMeshReply, error) {
meshId := in.MeshId
if meshId == "" {
return nil, errors.New("Must specify the meshId")
}
logging.Log.WriteInfof("MeshID: " + in.MeshId)
var token string = ""
return &rpc.JoinAuthMeshReply{Success: true, Token: &token}, nil
}