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