Skip to content

Commit 3d66033

Browse files
committed
Merge branch 'release/0.5.0'
2 parents a11b75c + c6e40a3 commit 3d66033

File tree

8 files changed

+305
-43
lines changed

8 files changed

+305
-43
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
build:
88
name: Build and Test
99
runs-on: ubuntu-latest
10+
#This check is case insensitive
11+
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
1012
outputs:
1113
artifact-version: ${{ steps.setversion.outputs.version }}
1214
env:
@@ -15,7 +17,7 @@ jobs:
1517
- uses: actions/checkout@v2
1618
- uses: actions/setup-java@v1
1719
with:
18-
java-version: 14
20+
java-version: 17
1921
- uses: actions/cache@v1
2022
with:
2123
path: ~/.m2/repository
@@ -29,8 +31,7 @@ jobs:
2931
id: setversion
3032
run: |
3133
v=$(mvn help:evaluate "-Dexpression=project.version" -q -DforceStdout)
32-
echo "::set-env name=BUILD_VERSION::${v}"
33-
echo "::set-output name=version::${v}"
34+
echo "BUILD_VERSION=${v}" >> $GITHUB_ENV
3435
- name: Build and Test
3536
run: mvn -B install
3637
- name: Upload snapshot artifact cryptomator-cli-${{ env.BUILD_VERSION }}.jar

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM alpine:3.12.0
2+
3+
ARG CRYPTOMATOR_CLI_VERSION=0.4.0
4+
5+
RUN adduser -D cryptomator && \
6+
apk add --no-cache openjdk11-jre-headless && \
7+
wget https://github.com/cryptomator/cli/releases/download/$CRYPTOMATOR_CLI_VERSION/cryptomator-cli-$CRYPTOMATOR_CLI_VERSION.jar -O /usr/bin/cryptomator.jar
8+
9+
USER cryptomator
10+
11+
VOLUME ["/vaults"]
12+
13+
ENTRYPOINT ["java", "-jar", "/usr/bin/cryptomator.jar"]

README.md

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,116 @@
33

44
# Cryptomator CLI
55

6-
This is a minimal command-line program that unlocks vaults which can then be accessed via an embedded WebDAV server.
6+
This is a minimal command-line application that unlocks vaults of vault format 8.
7+
After unlocking the vaults, its vault content can be accessed via an embedded WebDAV server.
8+
The minimum required Java version is JDK 17.
79

810
## Disclaimer
911

10-
This project is in an early stage and not ready for production use. We recommend to use it only for testing and evaluation purposes.
12+
:warning: This project is in an early stage and not ready for production use. We recommend using it only for testing and evaluation purposes.
1113

1214
## Download and Usage
1315

14-
Download the jar file via [GitHub Releases](https://github.com/cryptomator/cli/releases).
16+
Download the JAR file via [GitHub Releases](https://github.com/cryptomator/cli/releases).
1517

16-
Cryptomator CLI requires that at least JDK 11 is present on your system.
18+
Cryptomator CLI requires that at least JDK 17 is present on your system.
1719

1820
```sh
1921
java -jar cryptomator-cli-x.y.z.jar \
2022
--vault demoVault=/path/to/vault --password demoVault=topSecret \
2123
--vault otherVault=/path/to/differentVault --passwordfile otherVault=/path/to/fileWithPassword \
24+
--vault thirdVault=/path/to/thirdVault \
2225
--bind 127.0.0.1 --port 8080
23-
# you can now mount http://localhost:8080/demoVault/
26+
# You can now mount http://localhost:8080/demoVault/
27+
# The password for the third vault is read from stdin
28+
# Be aware that passing the password on the command-line typically makes it visible to anyone on your system!
2429
```
2530

26-
Then you can access the vault using any WebDAV client.
31+
## Filesystem Integration
32+
33+
Once the vault is unlocked and the WebDAV server started, you can access the vault by any WebDAV client or directly mounting it in your filesystem.
34+
35+
### Windows via Windows Explorer
36+
37+
Open the File Explorer, right click on "This PC" and click on the menu item "Map network drive...".
38+
39+
1. In the Drive list, select a drive letter. (Any available letter will do.)
40+
2. In the Folder box, enter the URL logged by the Cryptomator CLI application.
41+
3. Select Finish.
2742

2843
### Linux via davfs2
2944

30-
First, you need to create a mount point for your vault
45+
First, you need to create a mount point for your vault:
3146

3247
```sh
3348
sudo mkdir /media/your/mounted/folder
3449
```
3550

36-
Then you can mount the vault
51+
Then you can mount the vault:
3752

3853
```sh
39-
sudo mount -t davfs http://localhost:8080/demoVault/ /media/your/mounted/folder
54+
echo | sudo mount -t davfs -o username=,user,gid=1000,uid=1000 http://localhost:8080/demoVault/ /media/your/mounted/folder
55+
# Replace gid/uid with your gid/uid. The echo is used to skip over the password query from davfs
4056
```
4157

42-
To unmount the vault, run
58+
To unmount the vault, run:
4359

4460
```sh
4561
sudo umount /media/your/mounted/folder
4662
```
4763

4864
### macOS via AppleScript
4965

50-
Mount the vault with
66+
Mount the vault with:
5167

5268
```sh
5369
osascript -e 'mount volume "http://localhost:8080/demoVault/"'
5470
```
5571

56-
Unmount the vault with
72+
Unmount the vault with:
5773

5874
```sh
5975
osascript -e 'tell application "Finder" to if "demoVault" exists then eject "demoVault"'
6076
```
6177

78+
## Using as a Docker image
79+
80+
### Bridge Network with Port Forwarding
81+
82+
:warning: **WARNING: This approach should only be used to test the containerized approach, not in production.** :warning:
83+
84+
The reason is that with port forwarding, you need to listen on all interfaces. Other devices on the network could also access your WebDAV server and potentially expose your secret files.
85+
86+
Ideally, you would run this in a private Docker network with trusted containers built by yourself communicating with each other. **Again, the below example is for testing purposes only to understand how the container would behave in production.**
87+
88+
```sh
89+
docker run --rm -p 8080:8080 \
90+
-v /path/to/vault:/vaults/vault \
91+
-v /path/to/differentVault:/vaults/differentVault \
92+
-v /path/to/fileWithPassword:/passwordFile \
93+
cryptomator/cli \
94+
--bind 0.0.0.0 --port 8080 \
95+
--vault demoVault=/vaults/vault --password demoVault=topSecret \
96+
--vault otherVault=/vaults/differentVault --passwordfile otherVault=/passwordFile
97+
# You can now mount http://localhost:8080/demoVault/
98+
```
99+
100+
### Host Network
101+
102+
```sh
103+
docker run --rm --network=host \
104+
-v /path/to/vault:/vaults/vault \
105+
-v /path/to/differentVault:/vaults/differentVault \
106+
-v /path/to/fileWithPassword:/passwordFile \
107+
cryptomator/cli \
108+
--bind 127.0.0.1 --port 8080 \
109+
--vault demoVault=/vaults/vault --password demoVault=topSecret \
110+
--vault otherVault=/vaults/differentVault --passwordfile otherVault=/passwordFile
111+
# You can now mount http://localhost:8080/demoVault/
112+
```
113+
114+
Then you can access the vault using any WebDAV client.
115+
62116
## License
63117

64118
This project is dual-licensed under the AGPLv3 for FOSS projects as well as a commercial license derived from the LGPL for independent software vendors and resellers. If you want to use this library in applications, that are *not* licensed under the AGPL, feel free to contact our [support team](https://cryptomator.org/help/).

pom.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.cryptomator</groupId>
44
<artifactId>cli</artifactId>
5-
<version>0.4.0</version>
5+
<version>0.5.0</version>
66
<name>Cryptomator CLI</name>
77
<description>Command line program to access encrypted files via WebDAV.</description>
88
<url>https://github.com/cryptomator/cli</url>
99

1010
<properties>
11-
<cryptofs.version>1.9.10</cryptofs.version>
12-
<webdav-nio.version>1.0.11</webdav-nio.version>
13-
<commons.cli.version>1.4</commons.cli.version>
14-
<logback.version>1.2.3</logback.version>
11+
<cryptofs.version>2.3.1</cryptofs.version>
12+
<webdav-nio.version>1.2.6</webdav-nio.version>
13+
<commons.cli.version>1.5.0</commons.cli.version>
14+
<logback.version>1.2.9</logback.version>
15+
<fuse-nio.version>1.3.3</fuse-nio.version>
1516

16-
<java.version>11</java.version>
17+
<java.version>17</java.version>
1718
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1819
</properties>
1920

@@ -46,6 +47,11 @@
4647
<artifactId>webdav-nio-adapter</artifactId>
4748
<version>${webdav-nio.version}</version>
4849
</dependency>
50+
<dependency>
51+
<groupId>org.cryptomator</groupId>
52+
<artifactId>fuse-nio-adapter</artifactId>
53+
<version>${fuse-nio.version}</version>
54+
</dependency>
4955

5056
<!-- Commons -->
5157
<dependency>

src/main/java/org/cryptomator/cli/Args.java

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*******************************************************************************/
99
package org.cryptomator.cli;
1010

11+
import java.nio.file.Path;
1112
import java.nio.file.Paths;
1213
import java.util.HashMap;
1314
import java.util.Map;
@@ -71,22 +72,43 @@ public class Args {
7172
.valueSeparator() //
7273
.hasArgs() //
7374
.build());
75+
OPTIONS.addOption(Option.builder() //
76+
.longOpt("fusemount") //
77+
.argName("mount point") //
78+
.desc("Format must be vaultName=mountpoint") //
79+
.valueSeparator() //
80+
.hasArgs() //
81+
.build());
7482
}
7583

7684
private final String bindAddr;
7785
private final int port;
86+
private final boolean hasValidWebDavConfig;
7887
private final Properties vaultPaths;
7988
private final Properties vaultPasswords;
8089
private final Properties vaultPasswordFiles;
8190
private final Map<String, PasswordStrategy> passwordStrategies;
91+
private final Properties fuseMountPoints;
8292

8393
public Args(CommandLine commandLine) throws ParseException {
84-
this.bindAddr = commandLine.getOptionValue("bind", "localhost");
85-
this.port = Integer.parseInt(commandLine.getOptionValue("port", "0"));
94+
if (commandLine.hasOption("bind") && commandLine.hasOption("port")) {
95+
hasValidWebDavConfig = true;
96+
this.bindAddr = commandLine.getOptionValue("bind", "localhost");
97+
this.port = Integer.parseInt(commandLine.getOptionValue("port", "0"));
98+
} else {
99+
hasValidWebDavConfig = false;
100+
this.bindAddr = "";
101+
this.port = -1;
102+
}
86103
this.vaultPaths = commandLine.getOptionProperties("vault");
87104
this.vaultPasswords = commandLine.getOptionProperties("password");
88105
this.vaultPasswordFiles = commandLine.getOptionProperties("passwordfile");
89106
this.passwordStrategies = new HashMap<>();
107+
this.fuseMountPoints = commandLine.getOptionProperties("fusemount");
108+
}
109+
110+
public boolean hasValidWebDavConf() {
111+
return hasValidWebDavConfig;
90112
}
91113

92114
public String getBindAddr() {
@@ -118,15 +140,10 @@ public PasswordStrategy addPasswortStrategy(final String vaultName) {
118140
PasswordStrategy passwordStrategy = new PasswordFromStdInputStrategy(vaultName);
119141

120142
if (vaultPasswords.getProperty(vaultName) != null) {
121-
passwordStrategy = new PasswordFromPropertyStrategy(
122-
vaultName,
123-
vaultPasswords.getProperty(vaultName)
124-
);
143+
passwordStrategy = new PasswordFromPropertyStrategy(vaultName, vaultPasswords.getProperty(vaultName));
125144
} else if (vaultPasswordFiles.getProperty(vaultName) != null) {
126-
passwordStrategy = new PasswordFromFileStrategy(
127-
vaultName,
128-
Paths.get(vaultPasswordFiles.getProperty(vaultName))
129-
);
145+
passwordStrategy = new PasswordFromFileStrategy(vaultName,
146+
Paths.get(vaultPasswordFiles.getProperty(vaultName)));
130147
}
131148

132149
this.passwordStrategies.put(vaultName, passwordStrategy);
@@ -136,4 +153,13 @@ public PasswordStrategy addPasswortStrategy(final String vaultName) {
136153
public PasswordStrategy getPasswordStrategy(final String vaultName) {
137154
return passwordStrategies.get(vaultName);
138155
}
156+
157+
public Path getFuseMountPoint(String vaultName) {
158+
String mountPoint = fuseMountPoints.getProperty(vaultName);
159+
if (mountPoint == null) {
160+
return null;
161+
}
162+
Path mountPointPath = Paths.get(mountPoint);
163+
return mountPointPath;
164+
}
139165
}

0 commit comments

Comments
 (0)