Commit graph

2929 commits

Author SHA1 Message Date
Kevin Morris
b7475a5bd0
fix(rpc): fix performance of suggest[-pkgbase]
We were selecting the entire record; we should just select
the Name column as done in this commit.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-31 04:11:42 -07:00
Kevin Morris
61f3cb938c
feat(rpc): support the If-None-Match request header
If the If-None-Match header is supplied with a previously
obtained ETag from the same query, a 304 Not Modified is
returned with no content.

This allows clients to completely leverage the ETag header.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-31 01:22:54 -07:00
Kevin Morris
2cc44e8f28
fix(rpc): perform regex match against callback name
Since we're in the hot path, a constant re.compiled
JSONP_EXPR is defined for checks against the callback.

Additionally, reorganized `content_type` and `content`
to avoid performing a DB query when we encounter a
regex mismatch.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-31 01:17:16 -07:00
Kevin Morris
12b4269ba8
feat(rpc): support jsonp callbacks
This change introduces alternate rendering of text/javascript
JSONP-compatible callback content. The `examples/jsonp.html`
HTML document can be used to test this functionality against
a running aurweb server.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-31 00:29:19 -07:00
Kevin Morris
05e6cfca62
feat(rpc): add msearch type handler
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-30 22:56:18 -07:00
Kevin Morris
9fef8b0611
fix(rpc): fix search arg check
When by == 'maintainer', we allow an unspecified keyword,
resulting in a search of orphan packages. Fix our search
check so that when no arg is given, it is set to an empty
str().

We already check for valid args when type is not maintainer,
so there's no need to worry about other args falling through.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-30 22:53:30 -07:00
Kevin Morris
af2f3694e7
feat(rpc): add search type handler
This commit introduces a PackageSearch-derivative class: `RPCSearch`.
This derivative modifies callback behavior of PackageSearch to
suit RPC searches, including [make|check|opt]depends `by` types.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-30 19:25:54 -07:00
Kevin Morris
ece25e0499
Merge branch 'pu-rpc-suggest' into pu 2021-10-30 16:57:03 -07:00
Kevin Morris
c28f1695ed
fix(fastapi): support by maintainer search with no keywords
In this case, package search should return orphaned packages.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-30 16:24:53 -07:00
Kevin Morris
9d6dbaf0ec
feat(rpc): add suggest type handler
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-30 00:36:21 -07:00
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