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

web: provide a context for checking the status of the enterprise license #8153

Merged
merged 3 commits into from Jan 25, 2024

Conversation

kensternberg-authentik
Copy link
Contributor

@kensternberg-authentik kensternberg-authentik commented Jan 12, 2024

Details

There are a few places (currently 5) in our code where we have checks for the current enterprise licensing status of our product. While not particularly heavy or onerous, there's no reason to repeat those same lines, and since our UI is always running in the context of authentik, may as well make that status a client-side context in its own right. The status will update with an EVENT_REFRESH request.

A context-aware custom alert has also been provided; it draws itself (or nothing) depending on the state of the license, and the default message, "This feature requires an enterprise license," can be overriden with the notice property.

These two changes reduce the amount of code needed to manage our license alerting from 67 to 38 lines code, and while removing 29 lines from a product with 54,145 lines of code (a savings of 0.05%, oh boy!) isn't a miracle, it does mean there's a single source of truth for "Is this instance enterprise-licensed?" that's easy to access and use.

The internationalization files (including pseudolocale!) have been updated.

The text, "Provider require enterprise," has been changed to the default message. It was ungrammatical and, when used on the PropertyMappings page, didn't make sense in context.


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)
  • The translation files have been updated (make i18n-extract)

If applicable

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

There are a few places (currently 5) in our code where we have checks for the current enterprise
licensing status of our product. While not particularly heavy or onerous, there's no reason to
repeat those same lines, and since our UI is always running in the context of authentik, may as well
make that status a client-side context in its own right. The status will update with an
EVENT_REFRESH request.

A context-aware custom alert has also been provided; it draws itself (or `nothing`) depending on the
state of the license, and the default message, "This feature requires an enterprise license," can be
overriden with the `notice` property.

These two changes reduce the amount of code needed to manage our license alerting from 67 to 38
lines code, and while removing 29 lines from a product with 54,145 lines of code (a savings of
0.05%, oh boy!) isn't a miracle, it does mean there's a single source of truth for "Is this instance
enterprise-licensed?" that's easy to access and use.
Copy link

netlify bot commented Jan 12, 2024

Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit f3fa553
🔍 Latest deploy log https://app.netlify.com/sites/authentik-storybook/deploys/65b1ab2b8a81860007eedbc8
😎 Deploy Preview https://deploy-preview-8153--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

authentik translations instructions

Thanks for your pull request!

authentik translations are handled using Transifex. Please edit translations over there and they'll be included automatically.

Copy link

netlify bot commented Jan 12, 2024

Deploy Preview for authentik ready!

Name Link
🔨 Latest commit f3fa553
🔍 Latest deploy log https://app.netlify.com/sites/authentik/deploys/65b1ab2b97346e0008b64213
😎 Deploy Preview https://deploy-preview-8153--authentik.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@kensternberg-authentik kensternberg-authentik marked this pull request as ready for review January 12, 2024 22:28
@kensternberg-authentik kensternberg-authentik requested a review from a team as a code owner January 12, 2024 22:28
Copy link

codecov bot commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (035795d) 92.33% compared to head (f3fa553) 92.31%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8153      +/-   ##
==========================================
- Coverage   92.33%   92.31%   -0.02%     
==========================================
  Files         626      626              
  Lines       30921    30921              
==========================================
- Hits        28550    28544       -6     
- Misses       2371     2377       +6     
Flag Coverage Δ
e2e 50.63% <ø> (-0.02%) ⬇️
integration 26.13% <ø> (ø)
unit 89.58% <ø> (ø)

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 Author

@kensternberg-authentik kensternberg-authentik left a comment

Choose a reason for hiding this comment

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

A guided tour has been provided!

@@ -1,9 +1,13 @@
import { createContext } from "@lit-labs/context";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

1: Add the context name.

@@ -1,7 +1,9 @@
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

2: Retrieve and provide the context, _licenseSummary.

@@ -0,0 +1,25 @@
import { authentikEnterpriseContext } from "@goauthentik/elements/AuthentikContexts";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

3: Make the context easily accessible to others, including a specialized accessor for the most commonly accessed field.

@@ -0,0 +1,24 @@
import "@goauthentik/elements/Alert";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

4: Provide a notification mechanism for this particular setting.

After this, all the other changes are swapping out the ad-hoc request mechanisms to use the context instead.

@kensternberg-authentik kensternberg-authentik changed the title Web/lift license status to context web: provide a context for checking the status of the enterprise license Jan 12, 2024
Copy link
Contributor

github-actions bot commented Jan 12, 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-web-lift-license-status-to-context-1706143893-f3fa553
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-web-lift-license-status-to-context-1706143893-f3fa553-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-web-lift-license-status-to-context-1706143893-f3fa553

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-web-lift-license-status-to-context-1706143893-f3fa553-arm64

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

* main: (109 commits)
  translate: Updates for file web/xliff/en.xlf in fr (#8296)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in fr (#8295)
  website: update wording (#8290)
  enterrpise: exclude inactive users from license (#8294)
  web: bump API Client version (#8292)
  core: compile backend translations (#8291)
  events: migrate SystemTasks to DB (#8159)
  web/admin: fix footer links not being parsed on settings page (#8289)
  root: fix system check warnings (#8277)
  web: bump API Client version (#8288)
  enterprise: add full audit log [AUTH-458] (#8177)
  web: bump the esbuild group in /web with 2 updates (#8282)
  web: bump the sentry group in /web with 1 update (#8281)
  web: bump @codemirror/lang-html from 6.4.7 to 6.4.8 in /web (#8283)
  core: bump bandit from 1.7.6 to 1.7.7 (#8285)
  core: bump selenium from 4.16.0 to 4.17.2 (#8284)
  core: bump github.com/go-openapi/runtime from 0.26.2 to 0.27.0 (#8287)
  core: bump github.com/google/uuid from 1.5.0 to 1.6.0 (#8286)
  website/docs: Improve example nginx reverse proxy config (#8160)
  translate: Updates for file web/xliff/en.xlf in zh_CN (#8274)
  ...
@kensternberg-authentik kensternberg-authentik merged commit dcbfe73 into main Jan 25, 2024
69 checks passed
@kensternberg-authentik kensternberg-authentik deleted the web/lift-license-status-to-context branch January 25, 2024 17:21
kensternberg-authentik added a commit that referenced this pull request Jan 25, 2024
* main:
  web: provide a context for checking the status of the enterprise license (#8153)
kensternberg-authentik added a commit that referenced this pull request Jan 25, 2024
* main: (131 commits)
  web: provide a context for checking the status of the enterprise license (#8153)
  core: compile backend translations (#8311)
  translate: Updates for file web/xliff/en.xlf in zh-Hans (#8304)
  translate: Updates for file web/xliff/en.xlf in zh_CN (#8305)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in zh_CN (#8300)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in zh-Hans (#8301)
  events: fix missing labels on prometheus metrics (#8309)
  core: bump goauthentik.io/api/v3 from 3.2023106.4 to 3.2023106.5 (#8302)
  web: bump the wdio group in /tests/wdio with 4 updates (#8303)
  web: restore test anchor tag (#8298)
  translate: Updates for file web/xliff/en.xlf in fr (#8296)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in fr (#8295)
  website: update wording (#8290)
  enterrpise: exclude inactive users from license (#8294)
  web: bump API Client version (#8292)
  core: compile backend translations (#8291)
  events: migrate SystemTasks to DB (#8159)
  web/admin: fix footer links not being parsed on settings page (#8289)
  root: fix system check warnings (#8277)
  web: bump API Client version (#8288)
  ...
kensternberg-authentik added a commit that referenced this pull request Jan 25, 2024
* main: (119 commits)
  web: provide a context for checking the status of the enterprise license (#8153)
  core: compile backend translations (#8311)
  translate: Updates for file web/xliff/en.xlf in zh-Hans (#8304)
  translate: Updates for file web/xliff/en.xlf in zh_CN (#8305)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in zh_CN (#8300)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in zh-Hans (#8301)
  events: fix missing labels on prometheus metrics (#8309)
  core: bump goauthentik.io/api/v3 from 3.2023106.4 to 3.2023106.5 (#8302)
  web: bump the wdio group in /tests/wdio with 4 updates (#8303)
  web: restore test anchor tag (#8298)
  translate: Updates for file web/xliff/en.xlf in fr (#8296)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in fr (#8295)
  website: update wording (#8290)
  enterrpise: exclude inactive users from license (#8294)
  web: bump API Client version (#8292)
  core: compile backend translations (#8291)
  events: migrate SystemTasks to DB (#8159)
  web/admin: fix footer links not being parsed on settings page (#8289)
  root: fix system check warnings (#8277)
  web: bump API Client version (#8288)
  ...
kensternberg-authentik added a commit that referenced this pull request Jan 25, 2024
* main: (30 commits)
  web: clear out selecteds list after an API event to ensure a fresh copy of the policies-to-delete list (#8125)
  web: provide dual-list multiselect with pagination (#8004)
  web: provide a context for checking the status of the enterprise license (#8153)
  core: compile backend translations (#8311)
  translate: Updates for file web/xliff/en.xlf in zh-Hans (#8304)
  translate: Updates for file web/xliff/en.xlf in zh_CN (#8305)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in zh_CN (#8300)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in zh-Hans (#8301)
  events: fix missing labels on prometheus metrics (#8309)
  core: bump goauthentik.io/api/v3 from 3.2023106.4 to 3.2023106.5 (#8302)
  web: bump the wdio group in /tests/wdio with 4 updates (#8303)
  web: restore test anchor tag (#8298)
  translate: Updates for file web/xliff/en.xlf in fr (#8296)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in fr (#8295)
  website: update wording (#8290)
  enterrpise: exclude inactive users from license (#8294)
  web: bump API Client version (#8292)
  core: compile backend translations (#8291)
  events: migrate SystemTasks to DB (#8159)
  web/admin: fix footer links not being parsed on settings page (#8289)
  ...
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.

None yet

2 participants