Commit graph

2919 commits

Author SHA1 Message Date
Kevin Morris
a38e126f49
Merge branch 'fix-commit-hash-check' into pu 2021-10-30 00:06:28 -07:00
Kevin Morris
6d376fed15
feat(rpc): add ETag header with md5 hash content
The ETag header can be used for client-side caching.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 23:57:33 -07:00
Kevin Morris
0af6a2c32f
fix(docker): fix COMMIT_HASH variable check
The previous method was super bad. Even if a variable was declared,
if it was empty, we would run into a false-positive. Additionally,
the previous method did not allow us to not specify the COMMIT_HASH
variable; which is problematic for development environments.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 23:47:47 -07:00
Kevin Morris
b3b31394e8
fix(rpc): simplify json generation complexity
This simply decouples depends and relations population into
their own helper functions.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 22:59:40 -07:00
Kevin Morris
9464de108f
feat(fastapi): add /pkgbase/{name}/comments/{id}/edit (get)
This is needed so that users can edit comments when they don't have
Javascript being used in their browser.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 21:37:52 -07:00
Kevin Morris
01e27fa347
fix(fastapi): sanitize /requests params
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 20:40:00 -07:00
Kevin Morris
7f4c011dc3
fix(fastapi): sanitize PP/O parameters for package search
This definitely leaked through in more areas. We'll need to reuse
this new utility function in a few other routes in upcoming commits.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 20:39:55 -07:00
Kevin Morris
8dcdc7ff38
change(fastapi): decouple account comment templates
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 18:28:14 -07:00
Kevin Morris
46c39399ff
fix(fastapi): fix /account/{username} links
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 17:18:54 -07:00
Kevin Morris
348128fada
fix(fastapi): fix /account/{username} page title
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 17:18:53 -07:00
Kevin Morris
691b7b9091
feat(fastapi): add comment actions to /account/{username}/comments
With this change, we've decoupled some partials shared between
`/pkgbase/{name}` and `/account/{username}/comments`. The comment
actions template now resolves its package base via the `comment`
instance instead of requiring `pkgbase`.

We've also modified the existing package comment routes to
support execution from any location using the `next` parameter.
This allows us to reuse code from package comments for
account comments actions.

Moved the majority of comment editing javascript to its own
.js file.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 17:18:49 -07:00
Kevin Morris
adb6252f85
feat(fastapi): add /account/{username}/comments
This commit contains a base template of account comments
in sorted order (based on ColumnTS.desc).

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 13:21:16 -07:00
Kevin Morris
9fd07c36eb
fix(fastapi): fix account page title
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 12:12:13 -07:00
Kevin Morris
a3a5ec678c
fix(gitlab-ci): enable options.disable_http_login on aur-dev
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:20 -07:00
Kevin Morris
7ee32a4ea1
fix(gitlab-ci): set GIT_DATA_DIR=git_data on aur-dev
This uses the internally defined docker volume `git_data`,
but the variable is configurable for changes in the future.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:20 -07:00
Kevin Morris
8239dcdd1b
feat(docker): configure fastapi's commit_hash based on $COMMIT_HASH
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:20 -07:00
Kevin Morris
b49b629395
feat(gitlab-ci): set FASTAPI_WORKERS=5 on aur-dev
In addition, specify FASTAPI_BACKEND=gunicorn for deployment.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:19 -07:00
Kevin Morris
1c0543c07e
feat(docker): fixup and utilize AURWEB_(SSHD|FASTAPI|PHP)_PREFIX
Previously CGIT_CLONE_PREFIX_(PHP|FASTAPI), we found that we could
use the same env var in multiple places, including non-cgit-clone-prefix
areas.

So, they were renamed, and one additional prefix was added.

- CGIT_CLONE_PREFIX_PHP -> AURWEB_PHP_PREFIX
    - Used for cgit's clone prefix and AUR_CONFIG's aur_location for PHP
- CGIT_CLONE_PREFIX_FASTAPI -> AURWEB_FASTAPI_PREFIX
    - Used for cgit's clone prefix and AUR_CONFIG's aur_location for FastAPI
- AURWEB_SSHD_PREFIX
    - Used for aurweb's sshd clone prefix shown on package pages

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:19 -07:00
Kevin Morris
1656f5824d
fix(docker): restore mariadb service
Additionally, for now, no-op usage of the MARIADB_SOCKET_DIR
environment variable. This is particularly useful for a serious
production setup, but we don't currently use that.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:18 -07:00
Kristian Klausen
651c1cd8c6
feat(gitlab-ci): Add logic for deploying aur-dev with docker-compose
The infrastructure changes are here[1].

[1] https://gitlab.archlinux.org/archlinux/infrastructure/-/merge_requests/492
2021-10-28 08:19:16 -07:00
Kevin Morris
1f2347c6b4
fix(fastapi): fix User.login signature typing
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 07:35:20 -07:00
Kevin Morris
034288711b
fix(fastapi): rework cookies - do not re-emit generically
This change removes cookie re-emission of AURLANG and AURTZ,
adds the AURREMEMBER cookie (the state of the "Remember Me"
checkbox on login), and re-emits AURSID based on the AURREMEMBER
cookie.

Previously, re-emission of AURSID was forcefully modifying
the expiration of the AURSID cookie. The introduction of
AURREMEMBER allows us to deduct the correct cookie expiration
timing based on configuration variables. With this addition,
we now re-emit the AURSID cookie with an updated expiration
based on the "Remember Me" checkbox on login.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 07:35:14 -07:00
Kevin Morris
7418c33a30
add Account Request issue template
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-27 00:53:46 -07:00
Kevin Morris
d7ac95a707
fix(fastapi): limit cookie migration to whitelisted keys
Whitelisted keys: AURSID, AURTZ, AURLANG

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-26 19:09:39 -07:00
Kevin Morris
65be8b8e07
fix(fastapi): support "Account Type:" input for account edit
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-25 22:05:23 -07:00
Kevin Morris
7e7a1ead88
fix(fastapi): unify homepage cache expiry time to five minutes
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-24 19:08:03 -07:00
Kevin Morris
0d734eb07d
feat(fastapi): add configurable commit hash display
Two new options have been added:

- [devel] commit_url
    - URL including an %s format specifier that can be used to link
      to a webpage for the commit.
- [devel] commit_hash
    - HEAD's commit hash (produced via `git rev-parse HEAD`)

If a `[devel] commit_hash` is configured, a link to the commit based on
`[devel] commit_url` will be displayed in the aurweb footer in
the form: `HEAD@<commit_hash>`. If no `[devel] commit_url` is
configured, a non-linked hash will be displayed.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-24 18:12:19 -07:00
Kevin Morris
da55aa6491
fix(fastapi): use more credentials in archdev-navbar.html
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-23 20:57:43 -07:00
Kevin Morris
94d494866f
fix(fastapi): increase recursion limit during tests
The default recursion limit used by Docker's archlinux:base-devel
Python package becomes problematic in some cases when running tests
against our FastAPI application using starlette.testclient.TestClient
(aliased to fastapi.testclient.TestClient). starlette ends up with
test failures because it exceeds the recursion limit, but this only
happens when using the `TestClient`. When the ASGI servers are run,
this is not an issue and so in that case, the recursion limit has
not been touched.

This change uses a `TEST_RECURSION_LIMIT` environment variable to
modify the recursion limit of the FastAPI application. This variable
is, by default, only supplied when running pytests in Docker, but
can be force-supplied by the user.

TEST_RECURSION_LIMIT=10000 has been added to `.env` and `.gitlab-ci.yml`.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-23 20:15:53 -07:00
Kevin Morris
5fb75b9614
feat(fastapi): add /pkgbase/{name}/merge (post)
Changes:

- `via` is not required in FastAPI. We deduce the involved
  requests via their PackageBaseName / MergeBaseName columns
  and set them to Accepted when merged.
- When erroneous input is given, the error is now presented
  on the merge page instead of sending the user to the pkgbase
  page.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-23 19:03:32 -07:00
Kevin Morris
bc9bb045ed
fix(fastapi): PackageRequest's PackageBase relationship should not required
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-23 19:00:03 -07:00
Kevin Morris
6b065956f7
Merge branch 'pu_packages_action_delete' into pu 2021-10-23 18:48:46 -07:00
Kevin Morris
c6c04f4952
fix(docker): add missing version for docker-compose.override.yml
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-23 18:47:59 -07:00
Kevin Morris
60bffa4fb6
feat(FastAPI): add /packages (post) action: 'delete'
Improvements:

- Package deletion now creates a PackageRequest on behalf of
  the deleter if one does not yet exist.
- All package deletions are now logged to keep track of who did what.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-23 18:23:15 -07:00
Kevin Morris
81417ea8b2
change(docker): merge production git repo bind mount
This merge requires production users to specify an host
directory to bind as the git repository within Docker containers.

This means that a repository can be shared between host
and container, so that the repository does not need to be
managed within Docker alone.

New environment variables:

- GIT_DATA_DIR: Path to aur.git repository that is bind mounted

Do note, this variable only takes affect when users run
production Docker services, by supplying:

    $ docker-compose -f docker-compose.yml -f docker-compose.prod.yml ...
2021-10-22 21:34:58 -07:00
Kevin Morris
13b344d238
feat(FastAPI): add /packages (post) action: 'disown'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-22 19:38:14 -07:00
Kevin Morris
f1ad1b9aed
feat(FastAPI): add /packages (post) action: 'adopt'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-22 19:01:13 -07:00
Kevin Morris
9b5eeb7652
fix(pytest): ignore asyncio.base_events deprecation warnings
This deprecation warning is not fixed in a tagged release yet.
Ignoring it for now; it has nothing to do with user code.

Upstream bug at https://bugs.python.org/issue45097

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-22 18:52:10 -07:00
Kevin Morris
4ae3fbd5d1
change(docker): depend on provided poetry.lock for dep resolution
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-22 17:43:00 -07:00
Kevin Morris
d4210c53cf
fix: update poetry dependencies
There were some test failures caused by problematic
dependency versioning, most likely to to the seriously
braindead pyproject.toml config for deps that previously
existed.

This commit defines python version >=3.9<3.10 for our working
Python version and provides updated deps (to latest).

I believe the bug was originally caused by the fact that
we had no python dependency defined, allowing poetry to
resolve dependencies incorrectly for what we intended.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-22 17:39:59 -07:00
Kevin Morris
d5520c9ed2
feat(FastAPI): add /packages (post) action: 'unnotify'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 17:38:44 -07:00
Kevin Morris
b277d94e0b
feat(FastAPI): add /packages (post) action: 'notify'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 16:52:04 -07:00
Steven Guikal
e9fc27a33b feat(docker): make git data directory host-configurable
Signed-off-by: Steven Guikal <void@fluix.one>
2021-10-21 14:37:06 -04:00
Kevin Morris
fb85cb60a0
feat(FastAPI): add /packages (post) action: 'unflag'
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 11:29:55 -07:00
Kevin Morris
0b1c3ea539
feat(docker): expose cgit-{php,fastapi} on {13000,13001}
This change exposes the uwsgi daemon we use for cgit on:

- PHP: docker-host:13000
- FastAPI: docker-host:13001

These ports can then be used to take advantage of cgit on
a production server that hosts nginx in front of Docker.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 11:11:01 -07:00
Kevin Morris
db730ad8cb
fix(docker): fix cgit clone-prefix
Additionally, clone-prefix is now configurable via environment variables:

- CGIT_CLONE_PREFIX_PHP
- CGIT_CLONE_PREFIX_FASTAPI

These vars can be used by production to customize the clone prefix.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 11:11:01 -07:00
Kevin Morris
c4163547f6
fix(docker): swap package cgit -> cgit-aurweb
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 11:10:55 -07:00
Kevin Morris
65240c8343
feat(rpc): enforce ratelimiting
New configuration options:

- `[ratelimit] cache`
    - A boolean indicating whether we should use configured cache (1)
      or database (0) for ratelimiting.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 11:07:36 -07:00
Kevin Morris
6662975005
change(rpc): handle 'version' and 'type' arguments in constructor
Additionally, added RPC.error, which produces an RPC-compatible
error based on the version passed during construction.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 11:01:24 -07:00
Kevin Morris
a06f4ec19c
fix(fastapi): centralize logging initialization
With this change, we provide a wrapper to `logging.getLogger`
in the `aurweb.logging` module. Modules wishing to log using
logging.conf should get their module-local loggers by calling
`aurweb.logging.getLogger(__name__)`, similar to `logging.getLogger`,
this way initialization with logging.conf is guaranteed.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 10:40:52 -07:00