diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..7712e81 --- /dev/null +++ b/README.md | |||
@@ -0,0 +1,107 @@ | |||
1 | # A naively simple URL shortener | ||
2 | |||
3 |  | ||
4 | |||
5 |  | ||
6 | |||
7 | ## Installation | ||
8 | |||
9 | Only \*NIX systems are supported. | ||
10 | |||
11 | Runtime dependencies: | ||
12 | |||
13 | - cURL | ||
14 | |||
15 | - OpenSSL | ||
16 | |||
17 | - SQLite | ||
18 | |||
19 | Build dependencies: | ||
20 | |||
21 | - CMake | ||
22 | |||
23 | - A C++23 compiler | ||
24 | |||
25 | ### Building from source | ||
26 | |||
27 | 1. Clone the repo | ||
28 | |||
29 | 2. Go into the repo directory, and run `cmake -B build`. | ||
30 | |||
31 | 3. Run `cmake --build build -j`. | ||
32 | |||
33 | 4. Pick a data directory where the database will be created. | ||
34 | |||
35 | 5. Copy the `templates` and `statics` directories into the data | ||
36 | directory. | ||
37 | |||
38 | 6. Copy `build/shrt` into any directory that is in your `$PATH`. | ||
39 | |||
40 | ### Using pre-build binary | ||
41 | |||
42 | 1. Download the binary from one of the releases. | ||
43 | |||
44 | 2. Extract the downloaded tarball. | ||
45 | |||
46 | 3. Continue to step 4 in "Building from source". | ||
47 | |||
48 | ### Arch Linux package | ||
49 | |||
50 | A PKGBUILD is provided in `packages/arch` in this repository. | ||
51 | |||
52 | ## Configuartion | ||
53 | |||
54 | By default, shrt looks for a configuration file at `/etc/shrt.yaml`. | ||
55 | This path can be changed with the `-c` command line option. An example | ||
56 | configuration file is printed below with comments. | ||
57 | |||
58 | ``` yaml | ||
59 | # Specify the data directory you have picked. | ||
60 | data-dir: "/var/lib/shrt" | ||
61 | # The listening address. Example: localhost, 0.0.0.0, 127.0.0.1. | ||
62 | listen-address: localhost | ||
63 | # The port to listen to. If this is 0, the value of “listen-address” | ||
64 | # is treated as a path of a UNIX domain socket file. | ||
65 | listen-port: 8080 | ||
66 | # The client ID of your shrt service. This is given by the OpenID | ||
67 | # Connect provider. | ||
68 | client-id: shrt | ||
69 | # The client secrete of your shrt service. This is given by the OpenID | ||
70 | # Connect provider. | ||
71 | client-secret: "abced12345" | ||
72 | # The initial URL of the OpenID Connect service. | ||
73 | openid-url-prefix: "https://auth.example.com/" | ||
74 | # The base URL of your shrt service. This is usually just “https://” | ||
75 | # followed by your domain name. | ||
76 | base-url: https://go.mws.rocks | ||
77 | ``` | ||
78 | |||
79 | ### Authentication | ||
80 | |||
81 | Shrt relies on an external OpenID Connect service provider for | ||
82 | authentication. Usually you register your instance of shrt to the OpenID | ||
83 | Connect provider. The provider will give you an client ID and a client | ||
84 | secret (in this case your shrt server is the "client" of the OpenID | ||
85 | Connect service). An OpenID Connect service has a number of endpoints, | ||
86 | such as user info, tokens, etc. The URLs of those endpoints are discover | ||
87 | by visiting a URL that is constructed from the URL in the configuration | ||
88 | option `openid-url-prefix`, followed by | ||
89 | `.well-known/openid-configuration`. For example, if you set | ||
90 | `openid-url-prefix` to be `https://auth.example.com/`, the resulting URL | ||
91 | would be | ||
92 | |||
93 | https://auth.example.com/.well-known/openid-configuration | ||
94 | |||
95 | This method works on KeyCloak, but I have never tested this on other | ||
96 | OpenID Connect providers. | ||
97 | |||
98 | ### Base URL and shortcuts | ||
99 | |||
100 | For the configuration option `base-url`, usually this is just `https://` | ||
101 | followed by a domain that you own. Supposed you create a shortcut called | ||
102 | "search" which points to `https://google.com`, you would be able to | ||
103 | visit `https://your.domain/search` and be redirected to | ||
104 | `https://google.com`. However you do not have to use a root URL under | ||
105 | your domain. If you set `base-url` to `https://your.domain/some/path`, | ||
106 | your shortcut would be at `https://your.domain/some/path/search`. I do | ||
107 | not know why anybody would want this, but the capability is there. | ||