1. 10 Feb, 2022 1 commit
    • Kevin Morris's avatar
      change: report unhandled tracebacks to a repository · 7485cc23
      Kevin Morris authored
      
      
      As repeats of these traceback notifications were annoying some of
      the devops staff, and it took coordination to share tracebacks with
      developers, this commit removes that responsibility off of devops
      by reporting tracebacks to Gitlab repositories in the form of issues.
      
      - removed ServerErrorNotification
      - removed notifications.postmaster configuration option
      - added notifications.gitlab-instance option
      - added notifications.error-project option
      - added notifications.error-token option
      - added aurweb.exceptions.handle_form_exceptions, a POST route decorator
      
      Issues are filed confidentially. This change will need updates
      in infrastructure's ansible configuration before this can be
      applied to aur.archlinux.org.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
      7485cc23
  2. 08 Feb, 2022 1 commit
  3. 05 Feb, 2022 2 commits
  4. 18 Jan, 2022 2 commits
  5. 07 Jan, 2022 1 commit
  6. 06 Jan, 2022 2 commits
  7. 03 Jan, 2022 1 commit
    • Kevin Morris's avatar
      feat(auth): add requires_{auth,guest} decorators · 51b60f42
      Kevin Morris authored
      
      
      These new decorators are meant to be used without any arguments
      and provide aliases to auth_required:
      - `auth_required(True) -> requires_auth`
      - `auth_required(False) -> requires_guest`
      
      These decorators should be used without arguments, e.g.:
      
          @router.get("/")
          @requires_guest
          async def my_route(request: Request):
              return HTMLResponse()
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
      51b60f42
  8. 01 Dec, 2021 2 commits
  9. 30 Nov, 2021 1 commit
  10. 21 Oct, 2021 1 commit
    • Kevin Morris's avatar
      fix(fastapi): centralize logging initialization · a06f4ec1
      Kevin Morris authored
      
      
      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's avatarKevin Morris <kevr@0cost.org>
      a06f4ec1
  11. 17 Oct, 2021 2 commits
  12. 07 Oct, 2021 1 commit
  13. 03 Sep, 2021 1 commit
    • Kevin Morris's avatar
      [FastAPI] Refactor db modifications · a5943bf2
      Kevin Morris authored
      
      
      For SQLAlchemy to automatically understand updates from the
      external world, it must use an `autocommit=True` in its session.
      
      This change breaks how we were using commit previously, as
      `autocommit=True` causes SQLAlchemy to commit when a
      SessionTransaction context hits __exit__.
      
      So, a refactoring was required of our tests: All usage of
      any `db.{create,delete}` must be called **within** a
      SessionTransaction context, created via new `db.begin()`.
      
      From this point forward, we're going to require:
      
      ```
      with db.begin():
          db.create(...)
          db.delete(...)
          db.session.delete(object)
      ```
      
      With this, we now get external DB modifications automatically
      without reloading or restarting the FastAPI server, which we
      absolutely need for production.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
      a5943bf2
  14. 31 Aug, 2021 1 commit
  15. 01 Jul, 2021 1 commit
  16. 26 Jun, 2021 3 commits
    • Kevin Morris's avatar
      /tu/{proposal_id}: Do not show voters if there are none · 97c1247b
      Kevin Morris authored
      
      
      This was different than PHP.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
      97c1247b
    • Kevin Morris's avatar
      add /tu/{proposal_id} (get, post) routes · 85ba4a33
      Kevin Morris authored
      
      
      This commit ports the `/tu/?id={proposal_id}` PHP routes to
      FastAPI into two individual GET and POST routes.
      
      With this port of the single proposal view and POST logic,
      several things have changed.
      
      - The only parameter used is now `decision`, which
        must contain `Yes`, `No`, or `Abstain` as a string.
        When an invalid value is given, a BAD_REQUEST response
        is returned in plaintext: Invalid 'decision' value.
      - The `doVote` parameter has been removed.
      - The details section has been rearranged into a set
        of divs with specific classes that can be used for
        testing. CSS has been added to persist the layout with
        the element changes.
      - Several errors that can be discovered in the POST path
        now trigger their own non-200 HTTPStatus codes.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
      85ba4a33
    • Kevin Morris's avatar
      add /tu/ (get) index · d674aaf7
      Kevin Morris authored
      
      
      This commit implements the '/tu' Trusted User index page.
      
      In addition to this functionality, this commit introduces
      the following jinja2 filters:
      
      - dt: util.timestamp_to_datetime
      - as_timezone: util.as_timezone
      - dedupe_qs: util.dedupe_qs
      - urlencode: urllib.parse.quote_plus
      
      There's also a new decorator that can be used to enforce
      permissions: `account_type_required`. If a user does not
      meet account type requirements, they are redirected to '/'.
      
      ```
      @auth_required(True)
      @account_type_required({"Trusted User"})
      async def some_route(request: fastapi.Request):
          return Response("You are a Trusted User!")
      ```
      
      Routes added:
      
      - `GET /tu`: aurweb.routers.trusted_user.trusted_user
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
      d674aaf7