Skip to content

Commit 3c35b0e

Browse files
Merge pull request #20 from MaddyGuthridge/maddy-private-data-dir
Move private data to separate volume and modify firstrun workflow
2 parents 474c466 + 8c6abdf commit 3c35b0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+844
-518
lines changed

.env.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
HOST=localhost # the hostname to use
2-
PORT=5096 # the port number to use
3-
DATA_REPO_PATH="./data" # the path to the data repository
4-
AUTH_SECRET="CHANGE ME" # the secret key to validate tokens
1+
HOST=localhost # the hostname to use
2+
PORT=5096 # the port number to use
3+
DATA_REPO_PATH="./data" # the path to the data volume
4+
PRIVATE_DATA_PATH="./private_data" # the path to the private data volume

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
# Data directory
88
/data/
9+
# Private data directory
10+
/private_data/
911

1012
# Server logs
1113
*.log

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"cSpell.words": [
33
"Asciinema",
44
"firstrun",
5+
"Minifolio",
56
"superstruct"
67
]
78
}

docs/Files.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# File locations in Minifolio
2+
3+
## Data directory
4+
5+
Determined using environment variable `DATA_REPO_PATH`.
6+
7+
Main portfolio data. Should be backed up using a `git` repo.
8+
9+
### `config.json`
10+
11+
Main site configuration.
12+
13+
## Private data directory
14+
15+
Determined using environment variable `PRIVATE_DATA_PATH`.
16+
17+
Contains private data, including credentials and authentication secrets.
18+
19+
### `config.local.json`
20+
21+
Contains the local configuration of the server, including credentials and token
22+
info.
23+
24+
### `id_ed25519`, `id_ed25519.pub`
25+
26+
SSH key used by the server. These are used to perform git operations over SSH.
27+
28+
### `auth.secret`
29+
30+
Contains the authentication secret used by the server. This is used to validate
31+
JWTs.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "minifolio",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"private": true,
55
"license": "GPL-3.0-only",
66
"scripts": {

src/endpoints/admin/auth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function auth(token: string | undefined) {
2727
'POST',
2828
'/api/admin/auth/logout',
2929
token,
30-
)) as Promise<{ token: string }>;
30+
));
3131
};
3232

3333
/**
@@ -66,12 +66,12 @@ export default function auth(token: string | undefined) {
6666
* @param token The auth token
6767
* @param password The password to the admin account
6868
*/
69-
const disable = async (password: string) => {
69+
const disable = async (username: string, password: string) => {
7070
return json(apiFetch(
7171
'POST',
7272
'/api/admin/auth/disable',
7373
token,
74-
{ password }
74+
{ username, password }
7575
)) as Promise<Record<string, never>>;
7676
};
7777

src/endpoints/admin/firstrun.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/** Git repository endpoints */
2-
import type { FirstRunCredentials } from '$lib/server/auth';
32
import { apiFetch, json } from '../fetch';
43

54
/**
@@ -9,13 +8,15 @@ import { apiFetch, json } from '../fetch';
98
* @param branch The branch to check-out
109
*/
1110
export default async function (
12-
repoUrl: string | null,
13-
branch: string | null,
11+
username: string,
12+
password: string,
13+
repoUrl?: string | undefined,
14+
branch?: string | undefined,
1415
) {
1516
return json(apiFetch(
1617
'POST',
1718
'/api/admin/firstrun',
1819
undefined,
19-
{ repoUrl, branch },
20-
)) as Promise<{ credentials: FirstRunCredentials, firstTime: boolean }>;
20+
{ username, password, repoUrl, branch },
21+
)) as Promise<{ token: string, firstTime: boolean }>;
2122
}

src/endpoints/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export async function json(response: Promise<Response>): Promise<object> {
131131
}
132132

133133
if ([400, 401, 403].includes(res.status)) {
134-
// All 400 and 403 errors have an error message
134+
// All 400, 401 and 403 errors have an error message
135135
const message = (json as { message: string }).message;
136136
throw new ApiError(res.status, message);
137137
}

src/lib/server/auth/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Minifolio Auth
3+
*
4+
* Code for performing authorization in Minifolio.
5+
*
6+
* If you discover a security vulnerability, please disclose it responsibly.
7+
*/
8+
export { validateCredentials } from './passwords';
9+
export {
10+
generateToken,
11+
validateTokenFromRequest,
12+
isRequestAuthorized,
13+
redirectOnInvalidToken,
14+
} from './tokens';

0 commit comments

Comments
 (0)