Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: use custom json renderer for speed #9977

Merged
merged 3 commits into from
Jul 8, 2024
Merged

Conversation

rissson
Copy link
Member

@rissson rissson commented Jun 4, 2024

Details


Checklist

  • Local tests pass (ak test authentik/)
  • The code has been formatted (make lint-fix)

If an API change has been made

  • The API schema has been updated (make gen-build)

If changes to the frontend have been made

  • The code has been formatted (make web)

If applicable

  • The documentation has been updated
  • The documentation has been formatted (make website)

@rissson rissson self-assigned this Jun 4, 2024
@rissson rissson requested a review from a team as a code owner June 4, 2024 17:19
Copy link

netlify bot commented Jun 4, 2024

Deploy Preview for authentik-docs canceled.

Name Link
🔨 Latest commit b4c8f81
🔍 Latest deploy log https://app.netlify.com/sites/authentik-docs/deploys/668bffd2d091f20008090084

Copy link

netlify bot commented Jun 4, 2024

Deploy Preview for authentik-storybook canceled.

Name Link
🔨 Latest commit b4c8f81
🔍 Latest deploy log https://app.netlify.com/sites/authentik-storybook/deploys/668bffd20f58cd0009ca37f8

Copy link

codecov bot commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.62%. Comparing base (d6e7cb2) to head (b4c8f81).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9977      +/-   ##
==========================================
+ Coverage   92.61%   92.62%   +0.01%     
==========================================
  Files         714      714              
  Lines       35011    35012       +1     
==========================================
+ Hits        32426    32431       +5     
+ Misses       2585     2581       -4     
Flag Coverage Δ
e2e 49.60% <100.00%> (+0.01%) ⬆️
integration 25.37% <100.00%> (+<0.01%) ⬆️
unit 90.12% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Jun 4, 2024

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-ghcr.io/goauthentik/dev-server:gh-b4c8f81bcc46b662408df4ca0335c5a54567d6f7
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

For arm64, use these values:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-ghcr.io/goauthentik/dev-server:gh-b4c8f81bcc46b662408df4ca0335c5a54567d6f7-arm64
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
image:
    repository: ghcr.io/goauthentik/dev-server
    tag: gh-ghcr.io/goauthentik/dev-server:gh-b4c8f81bcc46b662408df4ca0335c5a54567d6f7

For arm64, use these values:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
image:
    repository: ghcr.io/goauthentik/dev-server
    tag: gh-ghcr.io/goauthentik/dev-server:gh-b4c8f81bcc46b662408df4ca0335c5a54567d6f7-arm64

Afterwards, run the upgrade commands from the latest release notes.

"""
Render object to JSON.

Adaptation of https://github.com/encode/django-rest-framework/blob/master/rest_framework/utils/encoders.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having all the cases in here, couldn't we just call the upstream function except for types that it isn't needed for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, the main issue is that the upstream one returns super().default(obj) which we may not want.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, actually we could

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tried, I can't get it to work with generators :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can have a look at (or even just use) https://github.com/brianjbuck/drf_orjson_renderer, since they don't seem to need this (also that repo switches the request parser to orjson too which we might as well do too)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's weird they don't implement it

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
@rissson rissson merged commit 5c8a9ab into main Jul 8, 2024
69 checks passed
@rissson rissson deleted the optimize-json-rendering branch July 8, 2024 15:27
kensternberg-authentik added a commit that referenced this pull request Jul 8, 2024
* main: (179 commits)
  website/integrations: add offline_access scope to DokuWiki (#10208)
  api: use custom json renderer for speed (#9977)
  core: bump github.com/sethvargo/go-envconfig from 1.0.3 to 1.1.0 (#10405)
  core: bump goauthentik.io/api/v3 from 3.2024060.5 to 3.2024060.6 (#10404)
  web: bump glob from 10.4.2 to 10.4.3 in /web (#10407)
  web: bump @swc/core from 1.6.7 to 1.6.13 in /web/sfe (#10408)
  core: bump ruff from 0.5.0 to 0.5.1 (#10390)
  web: bump @swc/cli from 0.3.14 to 0.4.0 in /web/sfe (#10394)
  core: bump certifi from 2024.2.2 to 2024.7.4 (#10398)
  web: bump @swc/core from 1.6.6 to 1.6.7 in /web/sfe (#10395)
  web: bump @sentry/browser from 8.14.0 to 8.15.0 in /web in the sentry group across 1 directory (#10388)
  website/integrations: aws: cleanup (#10355)
  web: bump API Client version (#10389)
  web/flows: Simplified flow executor (#10296)
  website/docs: sources: ldap: remove extra example (#10387)
  website/docs: add new content from old PR #9524 (#10158)
  stages/authenticator_validate: fix friendly_name being required (#10382)
  core: bump go api client (#10383)
  web: bump API Client version (#10381)
  outposts: make refresh interval configurable (#10138)
  ...
kensternberg-authentik added a commit that referenced this pull request Jul 10, 2024
* main:
  api: use custom json renderer for speed (#9977)
  core: bump github.com/sethvargo/go-envconfig from 1.0.3 to 1.1.0 (#10405)
  core: bump goauthentik.io/api/v3 from 3.2024060.5 to 3.2024060.6 (#10404)
  web: bump glob from 10.4.2 to 10.4.3 in /web (#10407)
  web: bump @swc/core from 1.6.7 to 1.6.13 in /web/sfe (#10408)
  core: bump ruff from 0.5.0 to 0.5.1 (#10390)
  web: bump @swc/cli from 0.3.14 to 0.4.0 in /web/sfe (#10394)
  core: bump certifi from 2024.2.2 to 2024.7.4 (#10398)
  web: bump @swc/core from 1.6.6 to 1.6.7 in /web/sfe (#10395)
  web: bump @sentry/browser from 8.14.0 to 8.15.0 in /web in the sentry group across 1 directory (#10388)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants