func (s *Server) AuthValidateToken(ctx context.Context, r *pb.AuthRequest) (*pb.Empty, error) {
	if _, err := s.Validate(r.GetToken()); err != nil {
		return &pb.Empty{}, ErrUnauthenticated
	}
	return &pb.Empty{}, nil
}
AuthValidateToken performs server-side verification of a previously
issued token.  This allows symmetric token algorithms to be used.
package rpc2
import (
	"context"
	"github.com/netauth/netauth/internal/token"
	types "github.com/netauth/protocol"
	pb "github.com/netauth/protocol/v2"
)
func (s *Server) AuthEntity(ctx context.Context, r *pb.AuthRequest) (*pb.Empty, error) {
	e := r.GetEntity()
	if err := s.ValidateSecret(e.GetID(), r.GetSecret()); err != nil {
		s.log.Info("Authentication Failed",
			"entity", e.GetID(),
			"service", getServiceName(ctx),
			"client", getClientName(ctx))
		return &pb.Empty{}, ErrUnauthenticated
	}
	s.log.Info("Authentication Succeeded",
		"entity", e.GetID(),
		"service", getServiceName(ctx),
		"client", getClientName(ctx))
	return &pb.Empty{}, nil
}
func (s *Server) AuthGetToken(ctx context.Context, r *pb.AuthRequest) (*pb.AuthResult, error) {
	_, err := s.AuthEntity(ctx, r)
	if err != nil {
		return &pb.AuthResult{}, err
	}
	caps := s.getCapabilitiesForEntity(*r.Entity.ID)
	tkn, err := s.Generate(
		token.Claims{
			EntityID:     r.GetEntity().GetID(),
			Capabilities: caps,
		},
		token.GetConfig(),
	)
	if err != nil {
		s.log.Warn("Error Issuing Token",
			"entity", r.GetEntity().GetID(),
			"capabilities", caps,
			"service", getServiceName(ctx),
			"client", getClientName(ctx),
			"error", err,
		)
		return &pb.AuthResult{}, ErrInternal
	}
	s.log.Info("Token Issued",
		"entity", r.GetEntity().GetID(),
		"capabilities", caps,
		"service", getServiceName(ctx),
		"client", getClientName(ctx),
	)
	return &pb.AuthResult{Token: &tkn}, nil
}