Commit graph

2423 commits

Author SHA1 Message Date
Frédéric Mangano-Tarumi
966f7bc186 Guard OAuth exceptions to provide better messages
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-28 20:46:15 -04:00
Frédéric Mangano-Tarumi
ba272783d4 HTML error pages for FastAPI
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-28 20:46:15 -04:00
Frédéric Mangano-Tarumi
36e7e84efa Update last login information on SSO login
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-28 20:46:15 -04:00
Frédéric Mangano-Tarumi
b64e195237 Stop redirecting stderr with proc_open
Error outputs were piped to a temporary buffer that wasn’t read by
anyone, making debugging hard because errors were completely silenced.
By not explicitly redirecting stderr on proc_open, the subprocess
inherits its parent stderr.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-27 17:38:06 -04:00
Frédéric Mangano-Tarumi
1910526ac7 aurweb.spawn: Support stdout redirections to non-tty
Only ttys have a terminal size. If we can’t obtain it, we’ll just use 80
as a sane default.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-27 17:38:05 -04:00
Kevin Morris
df3ebfa9e2 Exclude suspended Users from being notified
The existing notify.py script was grabbing entries regardless
of user suspension. This has been modified to only send notifications
to unsuspended users.

This change was written as a solution to
https://bugs.archlinux.org/task/65554.

Signed-off-by: Kevin Morris <kevr.gtalk@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-25 17:46:32 -04:00
Kevin Morris
7c0e5d5315 Support conjunctive keyword search in RPC interface
Newly supported API Version 6 modifies `type=search` for _by_ type
`name-desc`: it now behaves the same as `name-desc` search through the
https://aur.archlinux.org/packages/ search page.

Search for packages containing the literal keyword `blah blah` AND `haha`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg="blah blah"%20haha

Search for packages containing the literal keyword `abc 123`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg="abc 123"

The following example searches for packages that contain `blah` AND `abc`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg=blah%20abc

The legacy method still searches for packages that contain `blah abc`:
https://aur.archlinux.org/rpc/?v=5&type=search&arg=blah%20abc
https://aur.archlinux.org/rpc/?v=5&type=search&arg=blah%20abc

API Version 6 is currently only considered during a `search` of `name-desc`.

Note: This change was written as a solution to
https://bugs.archlinux.org/task/49133.

PS: + Some spacing issues fixed in comments.

Signed-off-by: Kevin Morris <kevr.gtalk@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-25 17:44:30 -04:00
Frédéric Mangano-Tarumi
1020dd6c24 Build a translation facility for FastAPI
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-25 17:44:30 -04:00
Frédéric Mangano-Tarumi
3a563095a3 SSO: Port account suspension
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-25 17:44:30 -04:00
Frédéric Mangano-Tarumi
1b218fa00d SSO: Port IP ban checking
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-25 17:44:30 -04:00
Frédéric Mangano-Tarumi
652ebdbf7e Save id_token for the SSO logout
As far as I can see, Keycloak ignores it entirely. I can login in as SSO
user A, then disconnect from the SSO directly and reconnect as user B,
but when I disconnect user A from AUR, Keycloak disconnects B even
though AUR passed it an ID token for A.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-14 18:48:31 -04:00
Frédéric Mangano-Tarumi
35eddac90b Implement SSO logout
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-14 18:48:31 -04:00
Frédéric Mangano-Tarumi
8ab1347034 SSO: Add an SSO option in the login page
We’ll probably change the whole login page in the future, but this makes
development easier.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-14 18:48:31 -04:00
Frédéric Mangano-Tarumi
0ac287dfa0 SSO: Explain the rationale behind prompt=login
We might reconsider it in the future.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-14 18:48:31 -04:00
Frédéric Mangano-Tarumi
c048cf21c0 Fix typos in CONTRIBUTING.md
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-07-14 18:48:31 -04:00
Frédéric Mangano-Tarumi
4c34cd980f Open AUR sessions from SSO
Only the core functionality is implemented here. See the TODOs.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-14 19:31:16 -04:00
Frédéric Mangano-Tarumi
6dd6e74041 Integrate SQLAlchemy into FastAPI
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-14 19:31:16 -04:00
Frédéric Mangano-Tarumi
714c0ff388 Add SSO account ID in table Users
This column holds a user ID issed by the single sign-on provider. For
Keycloak, it is an UUID. For more flexibility, we will be using a
standardly-sized VARCHAR field.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-14 19:31:16 -04:00
Frédéric Mangano-Tarumi
806f06c864 aurweb.l10n: Translate without side effects
The install method in Python’s gettext API aliases the translator’s
gettext method to an application-global _(). We don’t use that anywhere,
and it’s clear from aurweb’s Translator interface that we want to
translate a piece of text without affecting any global namespace.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-09 22:58:49 -04:00
Frédéric Mangano-Tarumi
b431bfbf34 Guide to setting up Keycloak for the SSO
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-06 09:11:17 -04:00
Frédéric Mangano-Tarumi
2004eb59ac Crude OpenID Connect client using Authlib
Developers can go to /sso/login to get redirected to the SSO. On
successful login, the ID token is displayed.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-06 09:10:14 -04:00
Frédéric Mangano-Tarumi
187a89ce9b aurweb.spawn: Fix isort errors
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-06 09:08:27 -04:00
Frédéric Mangano-Tarumi
561ec72694 Remove the FastAPI /hello test route
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-06 09:08:27 -04:00
Frédéric Mangano-Tarumi
9484e33e0d Introduce conf/config.dev for development
conf/config.dev’s purpose is to provide a lighter configuration template
for developers, and split development-specific options off the default
configuration file.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-02 20:07:53 -04:00
Frédéric Mangano-Tarumi
9cc71e497b aurweb.spawn: Integrate FastAPI and nginx
aurweb.spawn used to launch only PHP’s built-in server. Now it spawns a
dummy FastAPI application too. Since both stacks spawn their own HTTP
server, aurweb.spawn also spawns nginx as a reverse proxy to mount them
under the same base URL, defined by aur_location in the configuration.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-02 20:07:53 -04:00
Filipe Laíns
e19afce108 Add CONTRIBUTING.md
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-02 17:41:47 -04:00
Filipe Laíns
661e544d04 pre-commit: add initial config
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-02 17:41:47 -04:00
Filipe Laíns
40b4bf248d isort: add initial config
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-02 17:41:47 -04:00
Filipe Laíns
548f828e34 flake8: add initial config
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-02 17:41:47 -04:00
Filipe Laíns
2d00dcbe2e Refactor code to comply with flake8 and isort
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-06-02 17:41:44 -04:00
Filipe Laíns
9fa5c29878 ci: remove Travis CI
We are are moving to Gitlab CI.

Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-05-23 16:39:46 -04:00
Frédéric Mangano-Tarumi
b81786c340 Create aurweb.spawn for spawing the test server
This program makes it easier for developers to spawn the PHP server
since it fetches automatically what it needs from the configuration
file, rather than having the user explicitly pass arguments to the php
executable.

When the setup gets more complicated as we introduce Python,
aurweb.spawn will keep providing the same interface, while under the
hood it is planned to support running multiple sub-processes.

Its Python interface provides an way for the test suite to spawn the
test server when it needs to perform HTTP requests to the test server.

The current implementation is somewhat weak as it doesn’t detect when a
child process dies, but this is not supposed to happen often, and it is
only meant for aurweb developers.

In the long term, aurweb.spawn will eventually become obsolete, and
replaced by Docker or Flask’s tools.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-05-23 16:39:30 -04:00
Filipe Laíns
54c64ccea2 ci: add cache to gitlab ci
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-05-23 16:39:30 -04:00
Filipe Laíns
9278d25c88 ci: add gitlab ci
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-05-23 16:39:30 -04:00
Lukas Fleischer
169607f153 Fix PHP notices in the account form
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-04-05 15:59:56 -04:00
Lukas Fleischer
1369eb87b3 Fix invalid session ID check
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-04-05 15:59:55 -04:00
Lukas Fleischer
853ed9a950 Release 5.0.0
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-03-27 08:51:15 -04:00
Lukas Fleischer
279d8042e3 Add new upgrade instructions
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-03-27 08:49:34 -04:00
Lukas Fleischer
a09c4d8168 Translation updates from Transifex
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-03-27 08:31:46 -04:00
Frédéric Mangano-Tarumi
31a5b40b5c Map BIGINT to INTEGER for SQLite
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-03-22 16:50:10 -04:00
Frédéric Mangano-Tarumi
28ba3f77dc Write test/README.md to help working with tests
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-29 14:57:46 +01:00
Frédéric Mangano-Tarumi
bf7c49158c test/Makefile: Run tests with prove when available
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-29 14:56:47 +01:00
Frédéric Mangano-Tarumi
90c0a361b5 Support running tests from any directory
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-29 14:56:47 +01:00
Frédéric Mangano-Tarumi
e374a91feb Change the extension of TAP test suites to .t
This is the common convention for TAP, and makes harnesses like prove
automatically detect them. Plus, test suites don’t have to be shell
scripts anymore.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-27 16:44:36 +01:00
Frédéric Mangano-Tarumi
81d55e70ee Disable Alembic support on test databases
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-27 16:44:36 +01:00
Frédéric Mangano-Tarumi
e4cbe264cf Create an initial Alembic migration
This way the database will get stamped, and Git will create the
`versions` directory without which Alembic won’t work.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-27 16:44:36 +01:00
Frédéric Mangano-Tarumi
a8a1f74a92 Set up Alembic for database migrations
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-27 16:44:36 +01:00
Frédéric Mangano-Tarumi
7188743fc3 Migrate the database schema to SQLAlchemy
The new schema was generated with sqlacodegen and then manually adjusted
to fit schema/aur-schema.sql faithfully, both in the organisation of the
code and in the SQL generated by SQLAlchemy.

Initializing the database now requires the new tool aurweb.initdb.
References to aur-schema.sql have been updated and the old schema
dropped.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-27 16:44:36 +01:00
Lukas Fleischer
4b2102ceb2 Properly escape passwords in the account edit form
Addresses FS#65639.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-27 16:44:36 +01:00
Lukas Fleischer
cbab9870c1 Fix HTML code in the account search results table
Do not add an opening <tbody> tag for every row. Instead, wrap all rows
in <tbody></tbody>.

While at it, also simplify the code used to color the rows.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-26 13:51:18 +01:00