Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/dart/noports_core/lib/src/srvd/srvd_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class SrvdParams {
final String atSign;
final String homeDirectory;
final String atKeysFilePath;
final String passPhrase;
final String managerAtsign;
final String ipAddress;
final bool verbose;
Expand All @@ -30,6 +31,7 @@ class SrvdParams {
required this.atSign,
required this.homeDirectory,
required this.atKeysFilePath,
required this.passPhrase,
required this.managerAtsign,
required this.ipAddress,
required this.verbose,
Expand Down Expand Up @@ -58,6 +60,7 @@ class SrvdParams {
homeDirectory: homeDirectory,
atKeysFilePath:
r['key-file'] ?? getDefaultAtKeysFilePath(homeDirectory, atSign),
passPhrase: r['pass-phrase'],
managerAtsign: r['manager'],
ipAddress: r['ip'],
verbose: r['verbose'],
Expand Down Expand Up @@ -87,6 +90,16 @@ class SrvdParams {
'atSign\'s atKeys file if not in ~/.atsign/keys/'
' Alias: --keyFile',
);
parser.addOption(
'pass-phrase',
aliases: const ['passPhrase'],
abbr: 'P',
help:
'Pass Phrase to encrypt/decrypt the password protected atKeys file',
mandatory: false,
defaultsTo: '',
hide: true
);
parser.addOption(
'atsign',
abbr: 'a',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class SshnpArg {
profileNameArg,
helpArg,
keyFileArg,
passPhraseArg,
fromArg,
toArg,
deviceArg,
Expand Down Expand Up @@ -200,6 +201,14 @@ class SshnpArg {
help: 'Sending atSign\'s atKeys file if not in ~/.atsign/keys/',
parseWhen: ParseWhen.commandLine,
);
static const passPhraseArg = SshnpArg(
name: 'pass-phrase',
aliases: ['passPhrase'],
abbr: 'P',
help: 'Pass Phrase to encrypt/decrypt the password protected atKeys file',
mandatory: false,
defaultsTo: '',
);
static const fromArg = SshnpArg(
name: 'from',
abbr: 'f',
Expand Down
15 changes: 15 additions & 0 deletions packages/dart/noports_core/lib/src/sshnp/models/sshnp_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ abstract interface class ClientParams {

String? get atKeysFilePath;

String? get passPhrase;

/// An encryption keypair which should only ever reside in memory.
/// The public key is provided in requests to the daemon, and is
/// used by daemons to encrypt symmetric encryption keys intended for
Expand Down Expand Up @@ -83,6 +85,9 @@ abstract class ClientParamsBase implements ClientParams {
@override
final String? atKeysFilePath;

@override
final String? passPhrase;

@override
int localPort;

Expand Down Expand Up @@ -111,6 +116,7 @@ abstract class ClientParamsBase implements ClientParams {
this.device = DefaultSshnpArgs.device,
this.verbose = DefaultArgs.verbose,
this.atKeysFilePath,
this.passPhrase,
this.rootDomain = DefaultArgs.rootDomain,
this.authenticateClientToRvd = DefaultArgs.authenticateClientToRvd,
this.authenticateDeviceToRvd = DefaultArgs.authenticateDeviceToRvd,
Expand Down Expand Up @@ -180,6 +186,7 @@ class NptParams extends ClientParamsBase
super.localPort = DefaultSshnpArgs.localPort,
super.verbose = DefaultArgs.verbose,
super.atKeysFilePath,
super.passPhrase,
super.rootDomain = DefaultArgs.rootDomain,
super.authenticateClientToRvd = DefaultArgs.authenticateClientToRvd,
super.authenticateDeviceToRvd = DefaultArgs.authenticateDeviceToRvd,
Expand Down Expand Up @@ -258,6 +265,7 @@ class SshnpParams extends ClientParamsBase
this.remoteUsername,
this.tunnelUsername,
super.atKeysFilePath,
super.passPhrase,
super.rootDomain = DefaultArgs.rootDomain,
this.listDevices = DefaultSshnpArgs.listDevices,
this.remoteSshdPort = DefaultArgs.remoteSshdPort,
Expand Down Expand Up @@ -296,6 +304,7 @@ class SshnpParams extends ClientParamsBase
device: params2.device ?? params1.device,
localPort: params2.localPort ?? params1.localPort,
atKeysFilePath: params2.atKeysFilePath ?? params1.atKeysFilePath,
passPhrase: params2.passPhrase ?? params1.passPhrase,
identityFile: params2.identityFile ?? params1.identityFile,
identityPassphrase:
params2.identityPassphrase ?? params1.identityPassphrase,
Expand Down Expand Up @@ -364,6 +373,7 @@ class SshnpParams extends ClientParamsBase
remoteUsername: partial.remoteUsername,
tunnelUsername: partial.tunnelUsername,
atKeysFilePath: partial.atKeysFilePath,
passPhrase: partial.passPhrase,
rootDomain: partial.rootDomain ?? DefaultArgs.rootDomain,
listDevices: partial.listDevices ?? DefaultSshnpArgs.listDevices,
remoteSshdPort: partial.remoteSshdPort ?? DefaultArgs.remoteSshdPort,
Expand Down Expand Up @@ -417,6 +427,7 @@ class SshnpParams extends ClientParamsBase
SshnpArg.deviceArg.name: device,
SshnpArg.localPortArg.name: localPort,
SshnpArg.keyFileArg.name: atKeysFilePath,
SshnpArg.passPhraseArg.name: passPhrase,
SshnpArg.identityFileArg.name: identityFile,
SshnpArg.identityPassphraseArg.name: identityPassphrase,
SshnpArg.sendSshPublicKeyArg.name: sendSshPublicKey,
Expand Down Expand Up @@ -455,6 +466,7 @@ class SshnpPartialParams {
final String? device;
final int? localPort;
final String? atKeysFilePath;
final String? passPhrase;
final String? identityFile;
final String? identityPassphrase;
final bool? sendSshPublicKey;
Expand Down Expand Up @@ -485,6 +497,7 @@ class SshnpPartialParams {
this.device,
this.localPort,
this.atKeysFilePath,
this.passPhrase,
this.identityFile,
this.identityPassphrase,
this.sendSshPublicKey,
Expand Down Expand Up @@ -525,6 +538,7 @@ class SshnpPartialParams {
device: params2.device ?? params1.device,
localPort: params2.localPort ?? params1.localPort,
atKeysFilePath: params2.atKeysFilePath ?? params1.atKeysFilePath,
passPhrase: params2.passPhrase ?? params1.passPhrase,
identityFile: params2.identityFile ?? params1.identityFile,
identityPassphrase:
params2.identityPassphrase ?? params1.identityPassphrase,
Expand Down Expand Up @@ -585,6 +599,7 @@ class SshnpPartialParams {
device: args[SshnpArg.deviceArg.name],
localPort: args[SshnpArg.localPortArg.name],
atKeysFilePath: args[SshnpArg.keyFileArg.name],
passPhrase: args[SshnpArg.passPhraseArg.name],
identityFile: args[SshnpArg.identityFileArg.name],
identityPassphrase: args[SshnpArg.identityPassphraseArg.name],
sendSshPublicKey: args[SshnpArg.sendSshPublicKeyArg.name],
Expand Down
16 changes: 15 additions & 1 deletion packages/dart/noports_core/lib/src/sshnpd/sshnpd_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:at_cli_commons/at_cli_commons.dart';
import 'package:noports_core/src/common/default_args.dart';
import 'package:noports_core/src/common/types.dart';
import 'package:noports_core/src/common/validation_utils.dart';
import 'package:at_utils/at_utils.dart';

class SshnpdParams {
final String device;
Expand All @@ -13,6 +14,7 @@ class SshnpdParams {
final List<String> managerAtsigns;
final String? policyManagerAtsign;
final String atKeysFilePath;
final String passPhrase;
final String deviceAtsign;
final bool verbose;
final bool makeDeviceInfoVisible;
Expand All @@ -38,6 +40,7 @@ class SshnpdParams {
required this.managerAtsigns,
required this.policyManagerAtsign,
required this.atKeysFilePath,
required this.passPhrase,
required this.deviceAtsign,
required this.verbose,
required this.makeDeviceInfoVisible,
Expand All @@ -62,7 +65,7 @@ class SshnpdParams {
// Arg check
ArgResults r = parser.parse(args);

String deviceAtsign = r['atsign'];
String deviceAtsign = AtUtils.fixAtSign(r['atsign']);

if (!r.wasParsed('managers') && !r.wasParsed('policy-manager')) {
throw ArgumentError(
Expand Down Expand Up @@ -123,6 +126,7 @@ class SshnpdParams {
atKeysFilePath:
r['key-file'] ??
getDefaultAtKeysFilePath(homeDirectory, deviceAtsign),
passPhrase: r['pass-phrase'],
deviceAtsign: deviceAtsign,
verbose: r['verbose'],
makeDeviceInfoVisible: makeDeviceInfoVisible,
Expand Down Expand Up @@ -164,6 +168,16 @@ class SshnpdParams {
' Alias: --keyFile',
);

parser.addOption(
'pass-phrase',
aliases: ['passPhrase'],
abbr: 'P',
mandatory: false,
defaultsTo: '',
help: 'Pass Phrase to encrypt/decrypt the password protected atKeys file',
hide: true
);

parser.addOption(
'atsign',
abbr: 'a',
Expand Down
8 changes: 7 additions & 1 deletion packages/dart/sshnoports/bin/npt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ void main(List<String> args) async {
negatable: true,
);

parser.addOption('passPhrase',
abbr: 'P',
mandatory: false,
help: 'The pass phrase to access the password protected atKeys file');

parser.addOption(
'relay-auth-mode',
aliases: ['ram'],
Expand Down Expand Up @@ -376,7 +381,8 @@ void main(List<String> args) async {
homeDir: getHomeDirectory(),
storageDir: storageDir?.path,
verbose: parsedArgs['verbose'],
syncDisabled: true);
syncDisabled: true,
passPhrase: parsedArgs['passPhrase']);

await cliBase.init();

Expand Down
1 change: 1 addition & 0 deletions packages/dart/sshnoports/bin/srvd.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void main(List<String> args) async {
storagePath: storageDir.path,
atsign: p.atSign,
atKeysFilePath: p.atKeysFilePath,
passPhrase: p.passPhrase,
namespace: Srvd.namespace,
rootDomain: p.rootDomain,
atServiceFactory: ServiceFactoryWithNoOpSyncService(),
Expand Down
1 change: 1 addition & 0 deletions packages/dart/sshnoports/bin/sshnp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void main(List<String> args) async {
atsign: params.clientAtSign,
atKeysFilePath: params.atKeysFilePath ??
getDefaultAtKeysFilePath(homeDirectory, params.clientAtSign),
passPhrase: params.passPhrase,
rootDomain: params.rootDomain,
storagePath: storageDir!.path,
namespace: DefaultArgs.namespace,
Expand Down
1 change: 1 addition & 0 deletions packages/dart/sshnoports/bin/sshnpd.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void main(List<String> args) async {
atClientGenerator: (SshnpdParams p) => createAtClientCli(
atsign: p.deviceAtsign,
atKeysFilePath: p.atKeysFilePath,
passPhrase: p.passPhrase,
rootDomain: p.rootDomain,
storagePath: p.storagePath,
namespace: DefaultArgs.namespace,
Expand Down
2 changes: 2 additions & 0 deletions packages/dart/sshnoports/lib/src/create_at_client_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:path/path.dart' as path;
Future<AtClient> createAtClientCli({
required String atsign,
required String atKeysFilePath,
String? passPhrase = '',
required AtServiceFactory atServiceFactory,
required String storagePath,
required String namespace,
Expand All @@ -26,6 +27,7 @@ Future<AtClient> createAtClientCli({
..commitLogPath = path.normalize('$storagePath/commitLog')
..fetchOfflineNotifications = false
..atKeysFilePath = atKeysFilePath
..passPhrase = passPhrase
..rootDomain = domain
..rootPort = port;

Expand Down