forked from extern/smegmesh
Refactored client and server and interfaced out dependencies
This commit is contained in:
@@ -4,13 +4,14 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
||||
"github.com/tim-beatham/wgmesh/pkg/auth"
|
||||
logging "github.com/tim-beatham/wgmesh/pkg/log"
|
||||
"github.com/tim-beatham/wgmesh/pkg/rpc"
|
||||
)
|
||||
|
||||
type AuthRpcProvider struct {
|
||||
rpc.UnimplementedAuthenticationServer
|
||||
server *ctrlserver.MeshCtrlServer
|
||||
Manager *auth.JwtManager
|
||||
}
|
||||
|
||||
func (a *AuthRpcProvider) JoinMesh(ctx context.Context, in *rpc.JoinAuthMeshRequest) (*rpc.JoinAuthMeshReply, error) {
|
||||
@@ -20,7 +21,8 @@ func (a *AuthRpcProvider) JoinMesh(ctx context.Context, in *rpc.JoinAuthMeshRequ
|
||||
return nil, errors.New("Must specify the meshId")
|
||||
}
|
||||
|
||||
token, err := a.server.JwtManager.CreateClaims(in.MeshId, "sharedSecret")
|
||||
logging.InfoLog.Println("MeshID: " + in.MeshId)
|
||||
token, err := a.Manager.CreateClaims(in.MeshId, in.Alias)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -28,7 +30,3 @@ func (a *AuthRpcProvider) JoinMesh(ctx context.Context, in *rpc.JoinAuthMeshRequ
|
||||
|
||||
return &rpc.JoinAuthMeshReply{Success: true, Token: token}, nil
|
||||
}
|
||||
|
||||
func NewAuthProvider(ctrlServer *ctrlserver.MeshCtrlServer) *AuthRpcProvider {
|
||||
return &AuthRpcProvider{server: ctrlServer}
|
||||
}
|
||||
|
Reference in New Issue
Block a user