Compare commits

...
Author SHA1 Message Date
Teffen Ellis 5ceb78db72 web/elements: add Python suggestions to the code editor
- Suggest the keywords and builtins Monaco highlights Python with
- Suggest names already in the expression, found with Monaco's tokenizer
- Add block snippets
- Indent Python by four spaces

Expressions are the body of a function the server wraps them in, so the
context variables are not known here yet.
2026-11-04 17:50:25 +00:00
Teffen Ellis 86e347a6eb web/elements: add CSS suggestions to the code editor
- Run Monaco's CSS language service on the page for suggestions, hovers and validation
- Load each language's service with the first editor that uses it
- Add the suggestion widget, hovers and snippets

Monaco's own CSS entry point starts a worker whose setup loads every editor
feature, including the ones the editor leaves out.
2026-11-04 17:50:25 +00:00
Teffen EllisandDominic R e1669e3685 web/elements: replace CodeMirror with Monaco in the code editor
- Replace CodeMirror with Monaco, imported once the editor is shown
- Pick Monaco's editing features instead of loading all of them
- Add the One Dark theme, vendored from azemoh/vscode-onedark (MIT)
- Hold the field's height until the editor loads
- Follow changes to `mode`, `readonly` and `disabled`
- Honor `readonly`, which the CodeMirror element ignored

Co-authored-by: Dominic R <[email protected]>
2026-11-04 17:50:24 +00:00
Teffen EllisandDominic R 7961cc5a5d web/elements: rename ak-codemirror to ak-code-editor (#27406)
Name the element after what it is, not the library behind it, ahead of
replacing CodeMirror.

- Rename `<ak-codemirror>` to `<ak-code-editor>`
- Move `#elements/CodeMirror` to `#elements/CodeEditor`
- Rename `CodeMirrorMode` and the source helpers to match

Co-authored-by: Dominic R <[email protected]>
2026-11-04 17:50:19 +00:00
be54152697 website/integrations: add Google Cloud Workforce Identity Federation guide (#27571)
* adding google cloud integration documentation

* integrations: touch up

---------

Co-authored-by: Dominic R <[email protected]>
Co-authored-by: Dewi Roberts <[email protected]>
2026-11-04 17:46:42 +00:00
Emil Burzo 4569c221c1 root: test that FIPS mode refuses non-approved algorithms (#27536)
* root: test that FIPS mode refuses non-approved algorithms

* fix comment
2026-11-04 17:08:40 +00:00
dependabot[bot] f8cd97ebfb web: bump nanoid from 3.3.16 to 3.3.20 in /website (#27599)
Bumps [nanoid](https://github.com/ai/nanoid) from 3.3.16 to 3.3.20.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.3.16...3.3.20)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-version: 3.3.20
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-04 16:52:38 +00:00
dependabot[bot] a445660fa6 web: bump baseline-browser-mapping from 2.10.43 to 2.11.35 in /website (#27600)
Bumps [baseline-browser-mapping](https://github.com/web-platform-dx/baseline-browser-mapping) from 2.10.43 to 2.11.35.
- [Release notes](https://github.com/web-platform-dx/baseline-browser-mapping/releases)
- [Commits](https://github.com/web-platform-dx/baseline-browser-mapping/compare/v2.10.43...v2.11.35)

---
updated-dependencies:
- dependency-name: baseline-browser-mapping
  dependency-version: 2.11.35
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-04 16:52:32 +00:00
dependabot[bot] a6f130bcc3 web: bump mermaid from 11.16.1 to 11.17.2 in /web (#27603)
Bumps [mermaid](https://github.com/mermaid-js/mermaid) from 11.16.1 to 11.17.2.
- [Release notes](https://github.com/mermaid-js/mermaid/releases)
- [Commits](https://github.com/mermaid-js/mermaid/compare/[email protected]@11.17.2)

---
updated-dependencies:
- dependency-name: mermaid
  dependency-version: 11.17.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-04 16:52:26 +00:00
dependabot[bot] dc057d465b web: bump nanoid from 3.3.15 to 3.3.20 in /web (#27605)
Bumps [nanoid](https://github.com/ai/nanoid) from 3.3.15 to 3.3.20.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.3.15...3.3.20)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-version: 3.3.20
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-04 16:52:20 +00:00
dependabot[bot] 941b6bc9c0 web: bump postcss from 8.5.26 to 8.5.32 (#27607)
Bumps [postcss](https://github.com/postcss/postcss) from 8.5.26 to 8.5.32.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.5.26...8.5.32)

---
updated-dependencies:
- dependency-name: postcss
  dependency-version: 8.5.32
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-04 16:52:14 +00:00
dependabot[bot] ca5ce170d7 web: bump svgo from 3.3.4 to 3.3.5 (#27609)
Bumps [svgo](https://github.com/svg/svgo) from 3.3.4 to 3.3.5.
- [Release notes](https://github.com/svg/svgo/releases)
- [Commits](https://github.com/svg/svgo/compare/v3.3.4...v3.3.5)

---
updated-dependencies:
- dependency-name: svgo
  dependency-version: 3.3.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-04 16:52:07 +00:00
dependabot[bot] cd61e91eb8 web: bump baseline-browser-mapping from 2.10.43 to 2.11.35 (#27610)
Bumps [baseline-browser-mapping](https://github.com/web-platform-dx/baseline-browser-mapping) from 2.10.43 to 2.11.35.
- [Release notes](https://github.com/web-platform-dx/baseline-browser-mapping/releases)
- [Commits](https://github.com/web-platform-dx/baseline-browser-mapping/compare/v2.10.43...v2.11.35)

---
updated-dependencies:
- dependency-name: baseline-browser-mapping
  dependency-version: 2.11.35
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-04 16:52:01 +00:00
Ken Sternberg b9e1016592 web/admin: Fix “toggle group not centered on PolicyBindingForms” (#27543)
## Description

This commit adds a little CSS to ensure the toggle group is centered on the PolicyBindingForms.

The rule that “child components should not enforce their position or dimension; leave that to the client code to make those decisions” can sometimes make for awkward fits; in this case, a flex-wrapper to ensure centering.

The toggle group is also used in:

- ProxyProviderForm
- Ak-Application-Wizard-Edit-Binding-Steps
- BlueprintForm
- BlueprintImportForm

I have checked all five locations (the above, and PolicyBindingForms), and the toggle group is now centered in the Form in all cases.

Closes \#27357
2026-11-04 15:46:58 +00:00
Jens L. 5734217bc4 ci: fix codeql for python (#27611) 2026-11-04 15:39:17 +00:00
Emil Burzo bbd324fb19 core: bump fips-python from 3.14.10 to 3.14.10-p1 (#27597) 2026-11-04 15:33:49 +00:00
Jens L. f1341f57c0 flows: format titles correct on first render if possible (#27589)
Signed-off-by: Jens Langhammer <[email protected]>
2026-11-04 14:36:08 +00:00
Connor PeshekandJens Langhammer 2db2805965 common/saml: Add ability to select nameid unspecified (#27027)
* common/saml: Add ability to select nameid unspecified

* update help text for saml source nameid

* update ws-fed for unspecified and update provider docs

* no new migration

Signed-off-by: Jens Langhammer <[email protected]>

---------

Signed-off-by: Jens Langhammer <[email protected]>
Co-authored-by: Jens Langhammer <[email protected]>
2026-11-04 12:47:26 +00:00
101 changed files with 2459 additions and 1433 deletions

No files matched your search

+10 -2
View File
@@ -21,16 +21,24 @@ jobs:
strategy:
fail-fast: false
matrix:
language: ["go", "javascript", "python"]
language:
- lang: "go"
deps: "system,go,runtime"
- lang: "javascript"
deps: "system,node,runtime"
- lang: "python"
deps: "system,python,rust,runtime"
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v5
- name: Setup authentik env
uses: ./.github/actions/setup
with:
dependencies: ${{ matrix.language.deps }}
- name: Initialize CodeQL
uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
with:
languages: ${{ matrix.language }}
languages: ${{ matrix.language.lang }}
- name: Autobuild
uses: github/codeql-action/autobuild@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
- name: Perform CodeQL Analysis
+43 -33
View File
@@ -29,8 +29,8 @@ from authentik.flows.challenge import (
WithUserInfoChallenge,
)
from authentik.flows.exceptions import StageInvalidException
from authentik.flows.models import InvalidResponseAction
from authentik.flows.planner import PLAN_CONTEXT_APPLICATION, PLAN_CONTEXT_PENDING_USER
from authentik.flows.models import Flow, InvalidResponseAction
from authentik.flows.planner import PLAN_CONTEXT_APPLICATION, PLAN_CONTEXT_PENDING_USER, FlowPlan
from authentik.lib.avatars import DEFAULT_AVATAR, get_avatar
from authentik.lib.tracing import active_tracer
from authentik.lib.utils.reflection import class_to_path
@@ -44,6 +44,43 @@ HIST_FLOWS_STAGE_TIME = Histogram(
"Duration taken by different parts of stages",
["stage_type", "method"],
)
LOGGER = get_logger()
def _get_pending_user(plan: FlowPlan | None, request: HttpRequest, for_display=False) -> User:
"""Either show the matched User object or show what the user entered,
based on what the earlier stage (mostly IdentificationStage) set.
_USER_IDENTIFIER overrides the first User, as PENDING_USER is used for
other things besides the form display.
If no user is pending, returns request.user"""
if not plan:
return request.user
if PLAN_CONTEXT_PENDING_USER_IDENTIFIER in plan.context and for_display:
return User(
username=plan.context.get(PLAN_CONTEXT_PENDING_USER_IDENTIFIER),
email="",
)
if PLAN_CONTEXT_PENDING_USER in plan.context:
return plan.context[PLAN_CONTEXT_PENDING_USER]
return request.user
def format_flow_title(plan: FlowPlan | None, flow: Flow, request: HttpRequest) -> str:
"""Allow usage of placeholder in flow title."""
data = {
"app": "",
"user": "",
}
if plan:
data["app"] = plan.context.get(PLAN_CONTEXT_APPLICATION, "")
data["user"] = _get_pending_user(plan, request, for_display=True)
try:
return flow.title % data
except Exception as exc: # noqa
LOGGER.warning("failed to template title", exc=exc)
return flow.title
class StageView(View):
@@ -65,22 +102,7 @@ class StageView(View):
super().__init__(**kwargs)
def get_pending_user(self, for_display=False) -> User:
"""Either show the matched User object or show what the user entered,
based on what the earlier stage (mostly IdentificationStage) set.
_USER_IDENTIFIER overrides the first User, as PENDING_USER is used for
other things besides the form display.
If no user is pending, returns request.user"""
if not self.executor.plan:
return self.request.user
if PLAN_CONTEXT_PENDING_USER_IDENTIFIER in self.executor.plan.context and for_display:
return User(
username=self.executor.plan.context.get(PLAN_CONTEXT_PENDING_USER_IDENTIFIER),
email="",
)
if PLAN_CONTEXT_PENDING_USER in self.executor.plan.context:
return self.executor.plan.context[PLAN_CONTEXT_PENDING_USER]
return self.request.user
return _get_pending_user(self.executor.plan, self.request, for_display=for_display)
def cleanup(self):
"""Cleanup session"""
@@ -154,20 +176,6 @@ class ChallengeStageView(StageView):
):
return self.challenge_valid(challenge)
def format_title(self) -> str:
"""Allow usage of placeholder in flow title."""
if not self.executor.plan:
return self.executor.flow.title
try:
return self.executor.flow.title % {
"app": self.executor.plan.context.get(PLAN_CONTEXT_APPLICATION, ""),
"user": self.get_pending_user(for_display=True),
}
except Exception as exc: # noqa
self.logger.warning("failed to template title", exc=exc)
return self.executor.flow.title
@property
def cancel_url(self) -> str:
from authentik.flows.views.executor import NEXT_ARG_NAME, SESSION_KEY_GET
@@ -203,7 +211,9 @@ class ChallengeStageView(StageView):
# refreshes must mint fresh URLs instead of reusing cached ones.
flow_info = ContextualFlowInfo(
data={
"title": self.format_title(),
"title": format_flow_title(
self.executor.plan, self.executor.flow, self.request
),
"background": self.executor.flow.background_url(use_cache=False),
"background_themed_urls": self.executor.flow.background_themed_urls(
use_cache=False,
+1 -1
View File
@@ -22,7 +22,7 @@
{% include "base/header_js.html" %}
<meta name="ak-flow-layout" content="{{ flow.layout }}">
<meta name="ak-flow-background" content="{{ flow.background }}">
<meta name="ak-flow-title" content="{{ flow.title }}">
<meta name="ak-flow-title" content="{{ flow_title }}">
{% endblock %}
{% block interface_stylesheet %}
@@ -3,8 +3,12 @@
from django.test import RequestFactory
from django.urls import reverse
from authentik.core.models import Application
from authentik.core.tests.utils import create_test_flow
from authentik.flows.planner import PLAN_CONTEXT_APPLICATION, FlowPlan
from authentik.flows.stage import PLAN_CONTEXT_PENDING_USER_IDENTIFIER
from authentik.flows.tests import APIFlowTestCase
from authentik.flows.views.executor import SESSION_KEY_PLAN
from authentik.flows.views.interface import FlowInterfaceView
@@ -121,6 +125,52 @@ class TestFlowInterfaceTitle(APIFlowTestCase):
)
self.assertContains(response, '<meta name="ak-flow-title" content="100% secure">')
def test_title_plan_context(self):
"""Placeholders are filled from the plan in the session"""
flow = create_test_flow()
flow.title = "Sign in to %(app)s as %(user)s"
flow.save()
plan = FlowPlan(flow_pk=flow.pk.hex)
plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana")
plan.context[PLAN_CONTEXT_PENDING_USER_IDENTIFIER] = "jdoe"
session = self.client.session
session[SESSION_KEY_PLAN] = plan
session.save()
response = self.client.get(
reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug})
)
self.assertContains(
response, '<meta name="ak-flow-title" content="Sign in to Grafana as jdoe">'
)
def test_title_plan_other_flow(self):
"""A plan for a different flow still fills placeholders"""
flow = create_test_flow()
flow.title = "Sign in to %(app)s"
flow.save()
plan = FlowPlan(flow_pk=create_test_flow().pk.hex)
plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana")
session = self.client.session
session[SESSION_KEY_PLAN] = plan
session.save()
response = self.client.get(
reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug})
)
self.assertContains(response, '<meta name="ak-flow-title" content="Sign in to Grafana">')
def test_title_plan_invalid_placeholder(self):
"""Unknown placeholders with a plan keep the original title"""
flow = create_test_flow()
flow.title = "Hello %(foo)s"
flow.save()
session = self.client.session
session[SESSION_KEY_PLAN] = FlowPlan(flow_pk=flow.pk.hex)
session.save()
response = self.client.get(
reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug})
)
self.assertContains(response, '<meta name="ak-flow-title" content="Hello %(foo)s">')
class TestFlowInterfaceBackground(APIFlowTestCase):
"""Test the flow background on the interface page"""
+18 -9
View File
@@ -8,6 +8,8 @@ from ua_parser.user_agent_parser import Parse
from authentik.core.views.interface import InterfaceView
from authentik.flows.models import Flow
from authentik.flows.stage import format_flow_title
from authentik.flows.views.executor import SESSION_KEY_PLAN
# Oldest WebKit that can parse the default flow executor bundle. Earlier versions
# fail to parse it and render an empty page, so they are sent to the simplified
@@ -33,18 +35,25 @@ def version_below(version: dict[str, Any], minimum: tuple[int, int]) -> bool:
class FlowInterfaceView(InterfaceView):
"""Flow interface"""
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
flow = get_object_or_404(Flow, slug=self.kwargs.get("flow_slug"))
# Flow title formatted with a default dict, as we don't know the keys used
def get_formatted_flow_title(self, flow: Flow) -> str:
if "%(" not in flow.title:
return flow.title
if plan := self.request.session.get(SESSION_KEY_PLAN):
return format_flow_title(plan, flow, self.request)
# Fallback if we don't have a flow plan yet, format the title with an empty defaultdict
# Only format titles with named placeholders, as a bare "% s" would
# otherwise inline the dict's repr
if "%(" in flow.title:
try:
flow.title = (flow.title % defaultdict(str)).strip()
except TypeError, ValueError:
# If title formatting is invalid, keep the original title unchanged.
pass
try:
return (flow.title % defaultdict(str)).strip()
except TypeError, ValueError:
# If title formatting is invalid, keep the original title unchanged.
pass
return flow.title
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
flow = get_object_or_404(Flow, slug=self.kwargs.get("flow_slug"))
kwargs["flow"] = flow
kwargs["flow_title"] = self.get_formatted_flow_title(flow)
kwargs["flow_background_url"] = flow.background_url(self.request)
kwargs["flow_background_themed_urls"] = flow.background_themed_urls(self.request)
kwargs["inspector"] = "inspector" in self.request.GET
+58
View File
@@ -0,0 +1,58 @@
"""FIPS mode tests"""
import hashlib
from unittest import skipUnless
from cryptography.exceptions import InternalError, UnsupportedAlgorithm
from cryptography.hazmat.backends.openssl.backend import backend
from cryptography.hazmat.primitives import hashes, hmac
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
from cryptography.hazmat.primitives.kdf.scrypt import Scrypt
from django.test import SimpleTestCase
@skipUnless(backend._fips_enabled, "FIPS mode is off")
class TestFIPS(SimpleTestCase):
"""FIPS mode refuses algorithms that no FIPS standard approves. Ed25519 and ML-DSA aren't
checked: they're approved, the current FIPS provider just doesn't have them."""
def test_hashlib_md5(self):
"""MD5 for security use"""
with self.assertRaises(ValueError):
hashlib.md5(b"") # nosec
def test_hashlib_new(self):
"""hashlib.new() falls back to Python's builtin MD5, so these have no builtin"""
for name in ("ripemd160", "sm3", "md5-sha1"):
with self.subTest(name=name), self.assertRaises(ValueError):
hashlib.new(name, b"")
def test_hashlib_pbkdf2_md5(self):
"""PBKDF2 with MD5"""
with self.assertRaises(ValueError):
hashlib.pbkdf2_hmac("md5", b"", b"salt", 1)
def test_hashlib_scrypt(self):
"""scrypt"""
with self.assertRaises(ValueError):
hashlib.scrypt(b"", salt=b"salt", n=2, r=1, p=1)
def test_cryptography_md5(self):
"""MD5, which only fails once OpenSSL initializes the digest"""
with self.assertRaises((InternalError, UnsupportedAlgorithm)):
hashes.Hash(hashes.MD5()) # nosec
def test_cryptography_hmac_md5(self):
"""HMAC with MD5"""
with self.assertRaises(UnsupportedAlgorithm):
hmac.HMAC(b"key", hashes.MD5()) # nosec
def test_cryptography_scrypt(self):
"""scrypt"""
with self.assertRaises(UnsupportedAlgorithm):
Scrypt(salt=b"salt", length=32, n=2, r=1, p=1).derive(b"")
def test_cryptography_chacha20_poly1305(self):
"""ChaCha20-Poly1305"""
with self.assertRaises(UnsupportedAlgorithm):
ChaCha20Poly1305(b"k" * 32).encrypt(b"n" * 12, b"", None)
@@ -26,7 +26,7 @@ class Migration(migrations.Migration):
("urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", "Unspecified"),
],
default="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
help_text="NameID Policy sent to the IdP. Can be unset, in which case no Policy is sent.",
help_text="Format of the NameID Policy sent to the IdP. Select Unspecified to let the IdP choose the format of the NameID it returns.",
),
),
]
+2 -1
View File
@@ -126,7 +126,8 @@ class SAMLSource(Source):
choices=SAMLNameIDPolicy.choices,
default=SAMLNameIDPolicy.PERSISTENT,
help_text=_(
"NameID Policy sent to the IdP. Can be unset, in which case no Policy is sent."
"Format of the NameID Policy sent to the IdP. Select Unspecified to let the IdP "
"choose the format of the NameID it returns."
),
)
binding_type = models.CharField(
+1 -1
View File
@@ -13479,7 +13479,7 @@
"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"
],
"title": "Name id policy",
"description": "NameID Policy sent to the IdP. Can be unset, in which case no Policy is sent."
"description": "Format of the NameID Policy sent to the IdP. Select Unspecified to let the IdP choose the format of the NameID it returns."
},
"binding_type": {
"type": "string",
+1 -1
View File
@@ -83,7 +83,7 @@ RUN --mount=type=bind,target=rust-toolchain.toml,src=rust-toolchain.toml \
# Stage: Download uv
FROM ghcr.io/astral-sh/uv:0.13.7@sha256:96f40d3904aad8d0bd010539001d36c8e2188b981e1334471a90c4a1d93bb490 AS uv
# Stage: Base python image
FROM ghcr.io/goauthentik/fips-python:3.14.10-slim-trixie-fips@sha256:9f2478ddb774b8d4b2c2d91fa4d5d0cfd0172726a7b2e2e06fc200d9b3090f35 AS python-base
FROM ghcr.io/goauthentik/fips-python:3.14.10-p1-slim-trixie-fips@sha256:d4c46c4022b3545f4a2ad575b81a08d7effd9da44048d6018e393aee37508aaf AS python-base
ENV VENV_PATH="/ak-root/.venv" \
PATH="/lifecycle:/ak-root/.venv/bin:$PATH" \
+2 -1
View File
@@ -105,7 +105,8 @@ export interface PatchedSAMLSourceRequest {
*/
forceAuthn?: boolean;
/**
* NameID Policy sent to the IdP. Can be unset, in which case no Policy is sent.
* Format of the NameID Policy sent to the IdP. Select Unspecified to let the IdP choose the
* format of the NameID it returns.
*/
nameIdPolicy?: SAMLNameIDPolicyEnum;
bindingType?: BindingTypeEnum;
+2 -1
View File
@@ -136,7 +136,8 @@ export interface SAMLSource {
*/
forceAuthn?: boolean;
/**
* NameID Policy sent to the IdP. Can be unset, in which case no Policy is sent.
* Format of the NameID Policy sent to the IdP. Select Unspecified to let the IdP choose the
* format of the NameID it returns.
*/
nameIdPolicy?: SAMLNameIDPolicyEnum;
bindingType?: BindingTypeEnum;
+2 -1
View File
@@ -105,7 +105,8 @@ export interface SAMLSourceRequest {
*/
forceAuthn?: boolean;
/**
* NameID Policy sent to the IdP. Can be unset, in which case no Policy is sent.
* Format of the NameID Policy sent to the IdP. Select Unspecified to let the IdP choose the
* format of the NameID it returns.
*/
nameIdPolicy?: SAMLNameIDPolicyEnum;
bindingType?: BindingTypeEnum;
+536 -536
View File
File diff suppressed because it is too large. Load diff
+7 -7
View File
@@ -26568,7 +26568,7 @@ paths:
allOf:
- $ref: '#/components/schemas/SAMLNameIDPolicyEnum'
description: |+
NameID Policy sent to the IdP. Can be unset, in which case no Policy is sent.
Format of the NameID Policy sent to the IdP. Select Unspecified to let the IdP choose the format of the NameID it returns.
- $ref: '#/components/parameters/QueryPaginationOrdering'
- $ref: '#/components/parameters/QueryPaginationPage'
@@ -53878,8 +53878,8 @@ components:
name_id_policy:
allOf:
- $ref: '#/components/schemas/SAMLNameIDPolicyEnum'
description: NameID Policy sent to the IdP. Can be unset, in which case
no Policy is sent.
description: Format of the NameID Policy sent to the IdP. Select Unspecified
to let the IdP choose the format of the NameID it returns.
binding_type:
$ref: '#/components/schemas/BindingTypeEnum'
verification_kp:
@@ -58120,8 +58120,8 @@ components:
name_id_policy:
allOf:
- $ref: '#/components/schemas/SAMLNameIDPolicyEnum'
description: NameID Policy sent to the IdP. Can be unset, in which case
no Policy is sent.
description: Format of the NameID Policy sent to the IdP. Select Unspecified
to let the IdP choose the format of the NameID it returns.
binding_type:
$ref: '#/components/schemas/BindingTypeEnum'
verification_kp:
@@ -58325,8 +58325,8 @@ components:
name_id_policy:
allOf:
- $ref: '#/components/schemas/SAMLNameIDPolicyEnum'
description: NameID Policy sent to the IdP. Can be unset, in which case
no Policy is sent.
description: Format of the NameID Policy sent to the IdP. Select Unspecified
to let the IdP choose the format of the NameID it returns.
binding_type:
$ref: '#/components/schemas/BindingTypeEnum'
verification_kp:
+21
View File
@@ -2,6 +2,9 @@
* @file Bundler utilities.
*/
import { createRequire } from "node:module";
import { dirname, join } from "node:path";
import { NodeEnvironment, serializeEnvironmentVars } from "@goauthentik/core/environment/node";
import {
AuthentikVersion,
@@ -34,3 +37,21 @@ export function createBundleDefinitions() {
"process.env.NODE_ENV": SerializedNodeEnvironment,
};
}
/**
* Creates a mapping of import paths to the files a package ships without exporting them.
*/
export function createBundleAliases(): Record<string, string> {
const require = createRequire(import.meta.url);
return {
// Monaco's `exports` map covers only its modules. The editor renders in a shadow root,
// so it needs the stylesheet that its modules would otherwise inject into the document.
// `require` resolves the package to `min/vs/index.js`, next to that stylesheet.
"monaco-editor/min/vs/editor/editor.main.css": join(
dirname(require.resolve("monaco-editor")),
"editor",
"editor.main.css",
),
};
}
+2 -11
View File
@@ -157,13 +157,6 @@
}
},
"dependencies": {
"@codemirror/lang-css": "^6.3.1",
"@codemirror/lang-html": "^6.4.11",
"@codemirror/lang-javascript": "^6.2.5",
"@codemirror/lang-python": "^6.2.1",
"@codemirror/lang-xml": "^6.1.0",
"@codemirror/legacy-modes": "^6.5.3",
"@codemirror/theme-one-dark": "^6.1.3",
"@formatjs/intl-listformat": "^8.3.13",
"@fortawesome/fontawesome-free": "^7.3.1",
"@goauthentik/api": "link:packages/client-ts",
@@ -192,7 +185,6 @@
"@storybook/addon-links": "^10.6.1",
"@storybook/web-components": "^10.6.1",
"@storybook/web-components-vite": "^10.6.1",
"@types/codemirror": "^5.60.17",
"@types/grecaptcha": "^3.0.9",
"@types/guacamole-common-js": "^1.5.5",
"@types/node": "catalog:",
@@ -206,7 +198,6 @@
"change-case": "^5.4.4",
"chart.js": "^4.5.1",
"chartjs-adapter-date-fns": "^3.0.0",
"codemirror": "^6.0.2",
"cookie": "^2.0.1",
"core-js": "^3.49.0",
"country-flag-icons": "^1.6.20",
@@ -232,7 +223,8 @@
"lit-html": "^3.3.3",
"maplibre-gl": "^5.24.0",
"md-front-matter": "^1.0.4",
"mermaid": "^11.16.1",
"mermaid": "^11.17.2",
"monaco-editor": "^0.57.0",
"node-domexception": "workspace:*",
"npm-run-all": "^4.1.5",
"oxfmt": "catalog:",
@@ -251,7 +243,6 @@
"remark-gfm": "^4.0.1",
"remark-rehype": "^11.1.2",
"storybook": "^10.6.2",
"style-mod": "^4.1.3",
"stylelint": "^17.14.1",
"trusted-types": "^2.0.0",
"ts-pattern": "^5.9.0",
+55 -311
View File
@@ -210,27 +210,6 @@ importers:
.:
dependencies:
'@codemirror/lang-css':
specifier: ^6.3.1
version: 6.3.1
'@codemirror/lang-html':
specifier: ^6.4.11
version: 6.4.11
'@codemirror/lang-javascript':
specifier: ^6.2.5
version: 6.2.5
'@codemirror/lang-python':
specifier: ^6.2.1
version: 6.2.1
'@codemirror/lang-xml':
specifier: ^6.1.0
version: 6.1.0
'@codemirror/legacy-modes':
specifier: ^6.5.3
version: 6.5.3
'@codemirror/theme-one-dark':
specifier: ^6.1.3
version: 6.1.3
'@formatjs/intl-listformat':
specifier: ^8.3.13
version: 8.3.13
@@ -278,7 +257,7 @@ importers:
version: 1.0.3
'@mermaid-js/layout-elk':
specifier: ^0.2.2
version: 0.2.2([email protected]6.1)
version: 0.2.2([email protected]7.2)
'@mrmarble/djangoql-completion':
specifier: ^0.8.3
version: 0.8.3
@@ -315,9 +294,6 @@ importers:
'@storybook/web-components-vite':
specifier: ^10.6.1
version: 10.6.1([email protected])([email protected](@types/[email protected])([email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))
'@types/codemirror':
specifier: ^5.60.17
version: 5.60.17
'@types/grecaptcha':
specifier: ^3.0.9
version: 3.0.9
@@ -357,9 +333,6 @@ importers:
chartjs-adapter-date-fns:
specifier: ^3.0.0
version: 3.0.0([email protected])([email protected])
codemirror:
specifier: ^6.0.2
version: 6.0.2
cookie:
specifier: ^2.0.1
version: 2.0.1
@@ -436,8 +409,11 @@ importers:
specifier: ^1.0.4
version: 1.0.4
mermaid:
specifier: ^11.16.1
version: 11.16.1
specifier: ^11.17.2
version: 11.17.2
monaco-editor:
specifier: ^0.57.0
version: 0.57.0
node-domexception:
specifier: workspace:*
version: link:packages/node-domexception
@@ -492,9 +468,6 @@ importers:
storybook:
specifier: ^10.6.2
version: 10.6.2(@types/[email protected])([email protected])([email protected])
style-mod:
specifier: ^4.1.3
version: 4.1.3
stylelint:
specifier: ^17.14.1
version: 17.14.1([email protected])([email protected])
@@ -711,48 +684,6 @@ packages:
'@chevrotain/[email protected]':
resolution: {integrity: sha512-U+HFai5+zmJCkK86QsaJtoITlboZHBqrVketcO2ROv865xfCMSFpELQoz1GkX5GzME8pTa+3kbKrZHQtI0gdbw==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-tlosUqb+3BbxCxZdu4tKeRghPFC+QM7q4X5YhKV2eCmPG+1r2F3f4AaSz5sCrFqUtX4Jh20VFTKecl16MgiV9g==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-Ryk9y9T0FFVF0cUGhAknveAyUOl/A1qReTFi+qPKtOh2Z9F4AUBz3XOrYD4ZEgZirdugVzHvd/2/Wcwy5OliTg==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-9NsXp7Nwp891pQchI7gPdTwBuSuT3K65NGTHWHNJ55HjYcHLllr0rbIZNdOzas9ztc1EUVBlHou85FFZS4BNnw==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-IRjC8RUBhn9mGR9ywecNhB51yePWCGgvHfY1lWN/Mrp3cKuHr0isDKia+9HnvhiWNnMpbGhWrkhuWOc09exRyw==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-3z0blhicHLfwi2UgkZYRPioSgVTo9PV5GP5ducFH6FaHy0IAJRg+ixj5gTR1gnT/glAIC8xv4w2VL1LoZfs+Jg==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-1q4PaT+o6PbgpkJt4Q8Fv5XJxTy4FUZ4MWETtyiDw3J0Pyr9E2vqcKL+k9wcvjNTIsauxvE7OfmWj3FRPHQ76A==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-xCsmIzH78MyWkib9jlPaaun57XNkfbMIhagfaZVd0iLTqlpw3jXaIcbZm72MTmmn64eTZpBVNjbyYh+QXnxRsg==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-uMe5UO6PamJtSHrXhhHOzSX3ReWtiJrva6GnPMwSOrZtiExb5X5eExhr2OUZQVvdxPsKpY3Ro2mFbQadpPWmHA==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-Zbl9NyscLMZkfXPQnNAIIAFftidrA1UbcJEIMp24C0Bukc2I5T8wJS0wsXYsnDOqCFJUeJ1BITGNs5CqPDSmSg==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-NzBdIvEJmx6fjeremiGp3t/okrLPYT0d9orIc7AFun8oZcRk58aejkqhv6spnz4MLAevrKNPMQYXEWMg4s+sKA==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-YImu23iyKfncJzT7sRy+rEqEhSc8RhOHqDxwy4WzXRKJwYm6iwf/9OJk5ctCAdZ6yi2ZqaGEvmf55fSVqMDrgg==}
'@csstools/[email protected]':
resolution: {integrity: sha512-DtdHlgXh5ZkA43cwBcAm+huzgJiwx3ZTWVjBs94kwz2xKqSimDA3lBgCjphYgwgVUMWatSM0pDd8TILB1yrVVg==}
engines: {node: '>=20.19.0'}
@@ -1099,30 +1030,6 @@ packages:
'@kurkle/[email protected]':
resolution: {integrity: sha512-M5UknZPHRu3DEDWoipU6sE8PdkZ6Z/S+v4dD+Ke8IaNlpdSQah50lz1KtcFBa2vsdOnwbbnxJwVM4wty6udA5w==}
'@lezer/[email protected]':
resolution: {integrity: sha512-sxQE460fPZyU3sdc8lafxiPwJHBzZRy/udNFynGQky1SePYBdhkBl1kOagA9uT3pxR8K09bOrmTUqA9wb/PjSQ==}
'@lezer/[email protected]':
resolution: {integrity: sha512-N+tn9tej2hPvyKgHEApMOQfHczDJCwxrRFS3SPn9QjYN+uwHvEDnCgKRrb3mxDYxRS8sKMM8fhC3+lc04Abz5Q==}
'@lezer/[email protected]':
resolution: {integrity: sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==}
'@lezer/[email protected]':
resolution: {integrity: sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==}
'@lezer/[email protected]':
resolution: {integrity: sha512-vvYx3MhWqeZtGPwDStM2dwgljd5smolYD2lR2UyFcHfxbBQebqx8yjmFmxtJ/E6nN6u1D9srOiVWm3Rb4tmcUA==}
'@lezer/[email protected]':
resolution: {integrity: sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==}
'@lezer/[email protected]':
resolution: {integrity: sha512-MhQIURHRytsNzP/YXnqpYKW6la6voAH3kyplTOOiCdjyFY6cWWGFVmYVdHIPrElqSDf4iCDktQCockB9FxuhzQ==}
'@lezer/[email protected]':
resolution: {integrity: sha512-CdDwirL0OEaStFue/66ZmFSeppuL6Dwjlk8qk153mSQwiSH/Dlri4GNymrNWnUmPl2Um7QfV1FO9KFUyX3Twww==}
'@lit-labs/[email protected]':
resolution: {integrity: sha512-VHb0ALPMTlgKjM6yIxxoQNnpKyUKLD04VzeQdsiXkMqkvYlAHxq9glGLmgbb889/1GsohSOAjvQYoiBppXFqrQ==}
@@ -1178,9 +1085,6 @@ packages:
'@maplibre/[email protected]':
resolution: {integrity: sha512-j6p0AdjvAR19Z3XaCysle7A4ZSo08tYOzxD0Y9NQylwPAkwJJeYub5b2eVucdeDh7erhv69DahoLOevDRERRUw==}
'@marijn/[email protected]':
resolution: {integrity: sha512-FY+MKLBoTsLNJF/eLWaOsXGdz6uh3Iu1axjPf6TUq92IYumcTcXWHoS747JARLkcdlJ/Waiaxc5wQfFO8jC6NA==}
'@mdx-js/[email protected]':
resolution: {integrity: sha512-f++rKLQgUVYDAtECQ6fn/is15GkEH9+nZPM3MS0RcxVqoTfawHvDlSCH7JbMhAM6uJ32v3eXLvLmLvjGu7PTQw==}
peerDependencies:
@@ -1192,8 +1096,8 @@ packages:
peerDependencies:
mermaid: ^11.0.2
'@mermaid-js/[email protected].0':
resolution: {integrity: sha512-oYPyv8A4As1yH5Bx+04iQEQxXuIQDe0GKCNSRgao6z8AM9jixXIfP0vsppRLvGf+nKIOb9/LdpWA4YuJiVvESA==}
'@mermaid-js/[email protected].1':
resolution: {integrity: sha512-n12NohV3mrUyUL2o93IgG/ifeW9FTyeJn3zDxkhwa8MJ9Fxg3HQMlA3RiGmD/3UnJvheztkjjQAjA2T4LmUcpw==}
'@mrmarble/[email protected]':
resolution: {integrity: sha512-wYctvF0gQs48wL9jLQ+H2g2B0yJj7CrUSNi4ec5gcSuICIRqD/QSt6G+3zDdeW1LlI/4uj/FByJvg8k4TAAnVg==}
@@ -2738,9 +2642,6 @@ packages:
'@types/[email protected]':
resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==}
'@types/[email protected]':
resolution: {integrity: sha512-AZq2FIsUHVMlp7VSe2hTfl5w4pcUkoFkM3zVsRKsn1ca8CXRDYvnin04+HP2REkwsxemuHqvDofdlhUWNpbwfw==}
'@types/[email protected]':
resolution: {integrity: sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==}
@@ -2893,9 +2794,6 @@ packages:
'@types/[email protected]':
resolution: {integrity: sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA==}
'@types/[email protected]':
resolution: {integrity: sha512-ypzHFE/wBzh+BlH6rrBgS5I/Z7RD21pGhZ2rltb/+ZrVM1awdZwjx7hE5XfuYgHWk9uvV5HLZN3SloevCAp3Bw==}
'@types/[email protected]':
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
@@ -3324,9 +3222,6 @@ packages:
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
engines: {node: '>=12'}
[email protected]:
resolution: {integrity: sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==}
[email protected]:
resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==}
@@ -3414,9 +3309,6 @@ packages:
[email protected]:
resolution: {integrity: sha512-py8JiEKzjhYw6HPJ0L7SxLgCYim36UPRTZX43/kqGueUCZLSvnrqAiwW8HtQibur7mdkFQUkjOgdK+o/9FBtaw==}
[email protected]:
resolution: {integrity: sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==}
[email protected]:
resolution: {integrity: sha512-yyID2G7xhMPgVy+Kd6VPJC9s1czj5z1J8AaVsBmt5K5q9Ck9eEkWezMtm4Oe/D01Jg2K43edfhPIjk0qYEjZqA==}
hasBin: true
@@ -3712,6 +3604,9 @@ packages:
resolution: {integrity: sha512-gYzvtM72ZtxQO0T048kd6HWSbbGCNOUwcnfQ01cqIJ4X2IYKFFHZ5mKvrQETcFXxsRObZulDaKmy//R7TPtsBg==}
engines: {node: '>=20.19.0'}
[email protected]:
resolution: {integrity: sha512-EUBjM+B+lkDE41iE82DDSCfkoPGfXx8IxFxPMjNzm/Uk4xDet77rTN9wqlxlVg71kK7XGuUMv6wUxJUwwv+Xyw==}
[email protected]:
resolution: {integrity: sha512-B/pSlYVHQ58kqISD/yDjuJ1yfzI34m1gF4lAod2bwSRhiN4K5Cl3H8Af7hqB2PmTL911tdEudnnXn5FnhRoz0w==}
@@ -3923,6 +3818,9 @@ packages:
[email protected]:
resolution: {integrity: sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==}
[email protected]:
resolution: {integrity: sha512-LB+xjSTEbjHE1cWsxu+tN2Xqr1kpi+V9aADI7sVM5ZMaXyYGPHULQMzpJMYqOTULK/73pUkWVzzObFRBkPr+hg==}
[email protected]:
resolution: {integrity: sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==}
engines: {node: '>= 4.9.1'}
@@ -4710,6 +4608,11 @@ packages:
[email protected]:
resolution: {integrity: sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==}
[email protected]:
resolution: {integrity: sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==}
engines: {node: '>= 18'}
hasBin: true
[email protected]:
resolution: {integrity: sha512-TI3V8YYWvkVf3KJe1dRkpnjs68JUPyEa5vjKrp1XEEJUAOaQc+Qj+L1qWbPd0SJuAdQkFU0h73sXXqwDYxsiDA==}
engines: {node: '>= 20'}
@@ -4790,8 +4693,8 @@ packages:
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
engines: {node: '>= 8'}
[email protected]6.1:
resolution: {integrity: sha512-TQsq6u22fAn3rek5VOubrhKPo1g5hwC3FXUN9hiyupTckcYiGuuKGkNQrKYwGJkXUxZdojwRG46gsSCFZMDp4g==}
[email protected]7.2:
resolution: {integrity: sha512-V6K3C8EBdEsPFZXSKMJe6ppQOENxuHARr9GvHX4hh47lAbhMRD9qf4oEK7LoaRQxULMa80/qt5gHO73aCleBBg==}
[email protected]:
resolution: {integrity: sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==}
@@ -4929,6 +4832,9 @@ packages:
[email protected]:
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
[email protected]:
resolution: {integrity: sha512-5BkI9KGoqrNvBGUe15/QlZq3OooZ8WLg1AxTpaqHRCP3HNpzPPZKE2EDz8M7c+VRmCeUw1Brp4cx/PWm3kI/5A==}
[email protected]:
resolution: {integrity: sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==}
engines: {node: '>=10'}
@@ -4939,13 +4845,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw==}
[email protected].15:
resolution: {integrity: sha512-y7Wygv/7mEOvxTuEQDB8StXdMRBWf1kR/tlhAzBRUFkB2jfcLOAxO/SHmOO2zgz1pVgK29/kyupn059/bCHdjA==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
[email protected]:
resolution: {integrity: sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==}
[email protected].20:
resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
@@ -5704,6 +5605,9 @@ packages:
[email protected]:
resolution: {integrity: sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==}
[email protected]:
resolution: {integrity: sha512-cEmp9QeXXRmjj/rVp9oyiqcvyocWab/HaoN4+bwFeZ7QzykJD6L3yD4v12K1x0tHpqRqVpJevN3gW7kyM39Bqg==}
[email protected]:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
engines: {node: '>=8'}
@@ -5766,9 +5670,6 @@ packages:
resolution: {integrity: sha512-ki4hZQfh5rX0QDLLkOCj+h+CVNkqmp/CMf8v8kZpkNVK6jGQooMytqzLZYUVYIZcFZ6yDB70EfD8POcFXiF5oA==}
engines: {node: '>=18'}
[email protected]:
resolution: {integrity: sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==}
[email protected]:
resolution: {integrity: sha512-xVQwyiuxALUBNB2fBe0tmNemg9KqLtdj3T64mioFDar79B2cU8LIyz+3KL6LdiHs9NkeNfwxpKSaIVOY8f112g==}
engines: {node: '>=20.19.0'}
@@ -6159,9 +6060,6 @@ packages:
[email protected]:
resolution: {integrity: sha512-8TEXQxlldWAuIODdukIb+TR5s+9Ds40eSJrw+1iDDA9IFORPjMELarNQE3myz5XIkWWpdprmJjm1/SxMlWOC8A==}
[email protected]:
resolution: {integrity: sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==}
[email protected]:
resolution: {integrity: sha512-3hu+tD8YzSLGuFYtPRb48vdhKMi0KQV5sn+uWr8+7dMEq/2G/dtLrdDinkLjqq5TIbIBjYJ4Ax/n3YiaW7QM8A==}
engines: {node: 20 || >=22}
@@ -6343,110 +6241,6 @@ snapshots:
'@chevrotain/[email protected]': {}
'@codemirror/[email protected]':
dependencies:
'@codemirror/language': 6.12.4
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
'@lezer/common': 1.5.2
'@codemirror/[email protected]':
dependencies:
'@codemirror/language': 6.12.4
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
'@lezer/common': 1.5.2
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.20.3
'@codemirror/language': 6.12.4
'@codemirror/state': 6.7.0
'@lezer/common': 1.5.2
'@lezer/css': 1.3.4
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.20.3
'@codemirror/lang-css': 6.3.1
'@codemirror/lang-javascript': 6.2.5
'@codemirror/language': 6.12.4
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
'@lezer/common': 1.5.2
'@lezer/css': 1.3.4
'@lezer/html': 1.3.13
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.20.3
'@codemirror/language': 6.12.4
'@codemirror/lint': 6.9.7
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
'@lezer/common': 1.5.2
'@lezer/javascript': 1.5.4
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.20.3
'@codemirror/language': 6.12.4
'@codemirror/state': 6.7.0
'@lezer/common': 1.5.2
'@lezer/python': 1.1.19
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.20.3
'@codemirror/language': 6.12.4
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
'@lezer/common': 1.5.2
'@lezer/xml': 1.0.6
'@codemirror/[email protected]':
dependencies:
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
'@lezer/common': 1.5.2
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.10
style-mod: 4.1.3
'@codemirror/[email protected]':
dependencies:
'@codemirror/language': 6.12.4
'@codemirror/[email protected]':
dependencies:
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
crelt: 1.0.7
'@codemirror/[email protected]':
dependencies:
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
crelt: 1.0.7
'@codemirror/[email protected]':
dependencies:
'@marijn/find-cluster-break': 1.0.3
'@codemirror/[email protected]':
dependencies:
'@codemirror/language': 6.12.4
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
'@lezer/highlight': 1.2.3
'@codemirror/[email protected]':
dependencies:
'@codemirror/state': 6.7.0
crelt: 1.0.7
style-mod: 4.1.3
w3c-keyname: 2.2.8
'@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':
dependencies:
'@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])
@@ -6716,46 +6510,6 @@ snapshots:
'@kurkle/[email protected]': {}
'@lezer/[email protected]': {}
'@lezer/[email protected]':
dependencies:
'@lezer/common': 1.5.2
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.10
'@lezer/[email protected]':
dependencies:
'@lezer/common': 1.5.2
'@lezer/[email protected]':
dependencies:
'@lezer/common': 1.5.2
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.10
'@lezer/[email protected]':
dependencies:
'@lezer/common': 1.5.2
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.10
'@lezer/[email protected]':
dependencies:
'@lezer/common': 1.5.2
'@lezer/[email protected]':
dependencies:
'@lezer/common': 1.5.2
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.10
'@lezer/[email protected]':
dependencies:
'@lezer/common': 1.5.2
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.10
'@lit-labs/[email protected]': {}
'@lit/[email protected]':
@@ -6829,21 +6583,19 @@ snapshots:
'@types/geojson': 7946.0.16
pbf: 5.1.2
'@marijn/[email protected]': {}
'@mdx-js/[email protected](@types/[email protected])([email protected])':
dependencies:
'@types/mdx': 2.0.14
'@types/react': 19.3.0
react: 19.3.0
'@mermaid-js/[email protected]([email protected]6.1)':
'@mermaid-js/[email protected]([email protected]7.2)':
dependencies:
d3: 7.9.0
elkjs: 0.9.3
mermaid: 11.16.1
mermaid: 11.17.2
'@mermaid-js/[email protected].0':
'@mermaid-js/[email protected].1':
dependencies:
'@chevrotain/types': 11.1.2
@@ -8216,10 +7968,6 @@ snapshots:
'@types/deep-eql': 4.0.2
assertion-error: 2.0.1
'@types/[email protected]':
dependencies:
'@types/tern': 0.23.9
'@types/[email protected]': {}
'@types/[email protected]':
@@ -8389,10 +8137,6 @@ snapshots:
'@types/[email protected]': {}
'@types/[email protected]':
dependencies:
'@types/estree': 1.0.9
'@types/[email protected]': {}
'@types/[email protected]': {}
@@ -8903,16 +8647,6 @@ snapshots:
strip-ansi: 6.0.1
wrap-ansi: 7.0.0
[email protected]:
dependencies:
'@codemirror/autocomplete': 6.20.3
'@codemirror/commands': 6.10.4
'@codemirror/language': 6.12.4
'@codemirror/lint': 6.9.7
'@codemirror/search': 6.7.1
'@codemirror/state': 6.7.0
'@codemirror/view': 6.43.4
[email protected]:
dependencies:
color-name: 1.1.3
@@ -8978,8 +8712,6 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]:
@@ -9290,6 +9022,10 @@ snapshots:
dependencies:
domelementtype: 3.0.0
[email protected]:
optionalDependencies:
'@types/trusted-types': 2.0.7
[email protected]:
optionalDependencies:
'@types/trusted-types': 2.0.7
@@ -9607,6 +9343,10 @@ snapshots:
[email protected]: {}
[email protected]:
dependencies:
strictdom: 1.0.1
[email protected]: {}
[email protected]:
@@ -10403,6 +10143,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]: {}
@@ -10564,11 +10306,11 @@ snapshots:
[email protected]: {}
[email protected]6.1:
[email protected]7.2:
dependencies:
'@braintree/sanitize-url': 7.1.2
'@iconify/utils': 3.1.4
'@mermaid-js/parser': 1.2.0
'@mermaid-js/parser': 1.2.1
'@types/d3': 7.4.3
'@upsetjs/venn.js': 2.0.0
cytoscape: 3.34.0
@@ -10580,6 +10322,7 @@ snapshots:
dayjs: 1.11.21
dompurify: 3.4.17
es-toolkit: 1.50.0
fastdom: 1.0.12
katex: 0.16.47
khroma: 2.1.0
marked: 16.4.2
@@ -10833,15 +10576,18 @@ snapshots:
[email protected]: {}
[email protected]:
dependencies:
dompurify: 3.4.15
marked: 14.0.0
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected].15: {}
[email protected]: {}
[email protected].20: {}
[email protected]: {}
@@ -11263,13 +11009,13 @@ snapshots:
[email protected]:
dependencies:
nanoid: 3.3.15
nanoid: 3.3.20
picocolors: 1.1.1
source-map-js: 1.2.2
[email protected]:
dependencies:
nanoid: 3.3.16
nanoid: 3.3.20
picocolors: 1.1.1
source-map-js: 1.2.2
@@ -11806,6 +11552,8 @@ snapshots:
- bare-abort-controller
- react-native-b4a
[email protected]: {}
[email protected]:
dependencies:
emoji-regex: 8.0.0
@@ -11882,8 +11630,6 @@ snapshots:
dependencies:
'@tokenizer/token': 0.3.0
[email protected]: {}
[email protected]([email protected])([email protected]):
dependencies:
'@csstools/css-calc': 3.2.1(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])
@@ -12304,8 +12050,6 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]: {}
+2 -1
View File
@@ -11,7 +11,7 @@ import { copyAssets } from "./build-assets.ts";
import { localeManifestPlugin } from "#bundler/locale-manifest-plugin/node";
import { mdxPlugin } from "#bundler/mdx-plugin/node";
import { styleLoaderPlugin } from "#bundler/style-loader-plugin/node";
import { createBundleDefinitions } from "#bundler/utils/node";
import { createBundleAliases, createBundleDefinitions } from "#bundler/utils/node";
import { ConsoleLogger } from "#logger/node";
import { DistDirectory, EntryPoint, PackageRoot } from "#paths/node";
@@ -126,6 +126,7 @@ const BASE_ESBUILD_OPTIONS: BuildOptions = {
...(NodeEnvironment === "production" ? ["production"] : ["development", "production"]),
],
plugins: BASE_ESBUILD_PLUGINS,
alias: createBundleAliases(),
define: bundleDefinitions,
format: "esm",
};
@@ -1,6 +1,6 @@
import "#admin/admin-settings/AdminSettingsForm";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/EmptyState";
import "#elements/Tabs";
import "#elements/buttons/ModalButton";
@@ -1,5 +1,5 @@
import "#components/ak-text-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/ak-dual-select/ak-dual-select-dynamic-selected-provider";
import { ApplicationWizardProviderForm } from "#admin/applications/wizard/steps/providers/ApplicationWizardProviderForm";
import { AKAuthorizationFlowField } from "#admin/providers/components/flow-fields";
+5 -5
View File
@@ -1,7 +1,7 @@
import "#components/ak-text-input";
import "#elements/ToggleGroup";
import "#components/ak-switch-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/FormGroup";
import "#elements/forms/HorizontalFormElement";
import PFContent from "@patternfly/patternfly/components/Content/content.css";
@@ -179,11 +179,11 @@ export class BlueprintForm extends ModelForm<BlueprintInstance, string> {
label=${msg("Blueprint")}
name="content"
>
<ak-codemirror
<ak-code-editor
mode="yaml"
raw
value="${ifDefined(this.instance?.content)}"
></ak-codemirror>
></ak-code-editor>
</ak-form-element-horizontal>`
: nothing
}
@@ -193,11 +193,11 @@ export class BlueprintForm extends ModelForm<BlueprintInstance, string> {
<ak-form-group label="${msg("Additional settings")}">
<div class="pf-c-form">
<ak-form-element-horizontal label=${msg("Context")} name="context">
<ak-codemirror
<ak-code-editor
mode="yaml"
value="${YAML.stringify(this.instance?.context ?? {})}"
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Configure the blueprint context, used for templating.")}
</p>
+5 -5
View File
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Alert";
import "#elements/ak-dual-select/ak-dual-select-dynamic-selected-provider";
import "#elements/ak-dual-select/ak-dual-select-provider";
@@ -210,12 +210,12 @@ export class BrandForm extends ModelForm<Brand, string> {
msg("Custom CSS"),
)}
<ak-codemirror
<ak-code-editor
id="branding-custom-css"
mode="css"
value=${brandingCustomCss}
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Custom CSS to apply to pages when this brand is active.")}
</p>
@@ -382,14 +382,14 @@ export class BrandForm extends ModelForm<Brand, string> {
},
msg("Attributes"),
)}
<ak-codemirror
<ak-code-editor
id="attributes"
name="attributes"
mode="yaml"
value="${YAML.stringify(this.instance?.attributes ?? {})}"
aria-describedby="attributes-help"
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text" id="attributes-help">
${msg(
"Set custom attributes using YAML or JSON. Any attributes set here will be inherited by users, if the request is handled by this brand.",
@@ -1,6 +1,6 @@
import "#components/ak-secret-textarea-input";
import "#components/ak-text-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/buttons/ActionButton/index";
import "#elements/Expand";
import { aki } from "#common/api/client";
@@ -80,11 +80,11 @@ export class ConfigModal extends ModalButton {
text-closed=${msg("Show MDM configuration")}
text-open=${msg("Hide MDM configuration")}
>
<ak-codemirror
<ak-code-editor
mode="xml"
readonly
value="${ifDefined(this.config?.config)}"
></ak-codemirror>
></ak-code-editor>
</ak-expand>
</div>
<fieldset class="ak-c-fieldset pf-c-modal-box__footer">
@@ -2,7 +2,7 @@ import "#components/ak-secret-text-input";
import "#components/ak-switch-input";
import "#components/ak-text-input";
import "#elements/forms/FormGroup";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import { aki } from "#common/api/client";
import { ModelForm } from "#elements/forms/ModelForm";
@@ -61,10 +61,10 @@ export class GoogleChromeConnectorForm extends ModelForm<GoogleChromeConnector,
required
name="credentials"
>
<ak-codemirror
<ak-code-editor
mode="javascript"
.value="${this.instance?.credentials ?? {}}"
></ak-codemirror>
></ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Google Cloud credentials file.")}
</p>
@@ -3,7 +3,7 @@ import "#components/ak-radio-input";
import "#elements/forms/HorizontalFormElement";
import "#elements/forms/FormGroup";
import "#elements/utils/TimeDeltaHelp";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import { aki } from "#common/api/client";
import { ModelForm } from "#elements/forms/ModelForm";
@@ -99,11 +99,11 @@ export class EndpointDeviceForm extends ModelForm<EndpointDevice, string> {
})}
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("Attributes")} name="attributes">
<ak-codemirror
<ak-code-editor
mode="yaml"
value="${YAML.stringify(this.instance?.attributes ?? {})}"
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Set custom attributes using YAML or JSON.")}
</p>
@@ -1,6 +1,6 @@
import "#components/ak-secret-textarea-input";
import "#components/ak-text-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
import { EVENT_REFRESH_ENTERPRISE } from "#common/constants";
+1 -1
View File
@@ -5,7 +5,7 @@ import "#components/ak-object-attributes-card";
import "#admin/lifecycle/ObjectLifecyclePage";
import "#components/ak-status-label";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/buttons/ActionButton/index";
import "#elements/buttons/SpinnerButton/index";
+1 -1
View File
@@ -1,7 +1,7 @@
import "#admin/groups/ak-group-member-table";
import "#components/ak-switch-input";
import "#components/ak-text-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/ak-dual-select/ak-dual-select-provider";
import "#elements/chips/Chip";
import "#elements/chips/ChipGroup";
@@ -2,7 +2,7 @@ import "#components/ak-text-input";
import "#components/ak-switch-input";
import "#components/ak-number-input";
import "#elements/forms/FormGroup";
import "#elements/CodeMirror/ak-codemirror";
import "#elements/CodeEditor/ak-code-editor";
import { aki } from "#common/api/client";
import { groupBy } from "#common/utils";
@@ -153,8 +153,8 @@ export abstract class ObjectAttributeModelForm<
: html`<ak-form-group label=${msg("Advanced settings")}>
<div class="pf-c-form">
<ak-form-element-horizontal label=${msg("Attributes")} name="attributes">
<ak-codemirror mode="yaml" value="${YAML.stringify(values)}">
</ak-codemirror>
<ak-code-editor mode="yaml" value="${YAML.stringify(values)}">
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Set custom attributes using YAML or JSON.")}
</p>
+3 -3
View File
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/ak-dual-select/ak-dual-select-provider";
import "#elements/forms/FormGroup";
import "#elements/forms/HorizontalFormElement";
@@ -259,7 +259,7 @@ export class OutpostForm extends ModelForm<Outpost, string> {
msg("Configuration"),
)}
<ak-codemirror
<ak-code-editor
id="configuration"
name="config"
mode="yaml"
@@ -267,7 +267,7 @@ export class OutpostForm extends ModelForm<Outpost, string> {
this.instance ? this.instance.config : this.defaultConfig?.config,
)}"
aria-describedby="config-help"
></ak-codemirror>
></ak-code-editor>
<div id="config-help">
<p class="pf-c-form__helper-text">
${msg("Set custom attributes using YAML or JSON.")}
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import "#components/ak-switch-input";
import { aki } from "#common/api/client";
@@ -58,11 +58,11 @@ export class ServiceConnectionKubernetesForm extends ModelForm<
>
</ak-switch-input>
<ak-form-element-horizontal label=${msg("Kubeconfig")} name="kubeconfig">
<ak-codemirror
<ak-code-editor
mode="yaml"
value="${YAML.stringify(this.instance?.kubeconfig ?? {})}"
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Set custom attributes using YAML or JSON.")}
</p>
+27 -17
View File
@@ -23,7 +23,7 @@ import { Group, PoliciesApi, PolicyBinding, User } from "@goauthentik/api";
import { match, P } from "ts-pattern";
import { msg } from "@lit/localize";
import { CSSResult, html, nothing, TemplateResult } from "lit";
import { css, CSSResult, html, nothing, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators.js";
export type PolicyBindingNotice = { type: PolicyBindingCheckTarget; notice: string };
@@ -60,12 +60,20 @@ export function cleanBindingForSend(
return data;
}
const Styles = css`
.ak-c-form--centered-control {
display: flex;
justify-content: center;
align-items: center;
}
`;
@customElement("ak-policy-binding-form")
export class PolicyBindingForm<T extends PolicyBinding = PolicyBinding> extends ModelForm<
T,
string
> {
public static styles: CSSResult[] = [...super.styles, PFContent];
public static styles: CSSResult[] = [...super.styles, PFContent, Styles];
public static verboseName = msg("Policy Binding");
public static verboseNamePlural = msg("Policy Bindings");
@@ -158,22 +166,24 @@ export class PolicyBindingForm<T extends PolicyBinding = PolicyBinding> extends
}
renderModeSelector(): TemplateResult {
return html` <ak-toggle-group
value=${this.policyGroupUser}
@ak-toggle=${(ev: ToggleGroupEvent<PolicyBindingCheckTarget>) => {
this.policyGroupUser = ev.value;
}}
>
${Object.values(PolicyBindingCheckTarget).map((ct) => {
if (this.allowedTypes.includes(ct)) {
return html`<option value=${ct}>
${PolicyBindingCheckTargetToLabel(ct)}
</option>`;
}
return html`<div class="ak-c-form--centered-control">
<ak-toggle-group
value=${this.policyGroupUser}
@ak-toggle=${(ev: ToggleGroupEvent<PolicyBindingCheckTarget>) => {
this.policyGroupUser = ev.value;
}}
>
${Object.values(PolicyBindingCheckTarget).map((ct) => {
if (this.allowedTypes.includes(ct)) {
return html`<option value=${ct}>
${PolicyBindingCheckTargetToLabel(ct)}
</option>`;
}
return nothing;
})}
</ak-toggle-group>`;
return nothing;
})}
</ak-toggle-group>
</div>`;
}
protected renderTarget() {
+3 -3
View File
@@ -1,5 +1,5 @@
import "#components/ak-status-label";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/events/LogViewer";
import "#elements/forms/HorizontalFormElement";
import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";
@@ -142,12 +142,12 @@ export class PolicyTestForm extends Form<PolicyTestRequest> {
},
msg("Context"),
)}
<ak-codemirror
<ak-code-editor
id="context"
mode="yaml"
value=${YAML.stringify(this.request?.context ?? {})}
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Set custom attributes using YAML or JSON.")}
</p>
@@ -1,5 +1,5 @@
import "#components/ak-switch-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/FormGroup";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -62,11 +62,11 @@ export class ExpressionPolicyForm extends BasePolicyForm<ExpressionPolicy> {
required
name="expression"
>
<ak-codemirror
<ak-code-editor
mode="python"
value="${ifDefined(this.instance?.expression)}"
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Expression using Python.")}
<a
@@ -1,4 +1,4 @@
import "#elements/CodeMirror/ak-codemirror";
import "#elements/CodeEditor/ak-code-editor";
import "#components/ak-text-input";
import { docLink } from "#common/global";
@@ -45,8 +45,8 @@ export abstract class BasePropertyMappingForm<T extends PropertyMapping> extends
</ak-text-input>
${this.renderExtraFields()}
<ak-form-element-horizontal label=${msg("Expression")} required name="expression">
<ak-codemirror mode="python" value="${ifDefined(this.instance?.expression)}">
</ak-codemirror>
<ak-code-editor mode="python" value="${ifDefined(this.instance?.expression)}">
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Expression using Python.")}
<a target="_blank" rel="noopener noreferrer" href=${docLink(this.docLink)}>
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/FormGroup";
import "#elements/forms/HorizontalFormElement";
import "#elements/forms/Radio";
@@ -130,11 +130,11 @@ export class PropertyMappingProviderRACForm extends BasePropertyMappingForm<RACP
<ak-form-group label="${msg("Advanced settings")}">
<div class="pf-c-form">
<ak-form-element-horizontal label=${msg("Expression")} name="expression">
<ak-codemirror
<ak-code-editor
mode="python"
value="${ifDefined(this.instance?.expression)}"
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Expression using Python.")}
<a
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
import { PFSize } from "#common/enums";
@@ -89,13 +89,13 @@ export class PropertyMappingTestForm extends Form<PropertyMappingTestRequest> {
msg("Result"),
)}
<ak-codemirror
<ak-code-editor
id="result"
mode="javascript"
readonly
value="${ifDefined(this.result?.result)}"
>
</ak-codemirror>`
</ak-code-editor>`
: html`<div class="pf-c-form__group-label">
<div class="c-form__horizontal-group">
<span class="pf-c-form__label-text">
@@ -205,12 +205,12 @@ export class PropertyMappingTestForm extends Form<PropertyMappingTestRequest> {
},
msg("Context"),
)}
<ak-codemirror
<ak-code-editor
id="context"
mode="yaml"
value=${YAML.stringify(this.request?.context ?? {})}
>
</ak-codemirror>
</ak-code-editor>
</ak-form-element-horizontal>
${this.result ? this.renderResult() : null}`;
}
@@ -1,5 +1,5 @@
import "#components/ak-radio-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#components/ak-number-input";
import "#components/ak-switch-input";
import "#elements/utils/TimeDeltaHelp";
@@ -58,10 +58,10 @@ export class GoogleWorkspaceProviderFormPage extends BaseProviderForm<GoogleWork
required
name="credentials"
>
<ak-codemirror
<ak-code-editor
mode="javascript"
.value="${this.instance?.credentials ?? {}}"
></ak-codemirror>
></ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Google Cloud credentials file.")}
</p>
@@ -2,7 +2,7 @@ import "#admin/providers/RelatedApplicationButton";
import "#admin/providers/ldap/LDAPProviderForm";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/buttons/ModalButton";
import "#elements/buttons/SpinnerButton/index";
@@ -6,7 +6,7 @@ import "#admin/providers/RelatedApplicationButton";
import "#admin/events/ObjectChangelog";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#admin/rbac/ObjectPermissionModal";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/EmptyState";
import "#elements/Tabs";
import "#elements/ak-mdx/index";
@@ -3,7 +3,7 @@ import "#admin/providers/proxy/ProxyProviderForm";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#components/ak-status-label";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/ak-mdx/index";
import "#elements/buttons/ModalButton";
@@ -1,7 +1,7 @@
import "#components/ak-text-input";
import "#components/ak-switch-input";
import "#components/ak-number-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/ak-dual-select/ak-dual-select-dynamic-selected-provider";
import "#elements/forms/FormGroup";
import "#elements/forms/HorizontalFormElement";
@@ -127,11 +127,11 @@ export class RACProviderFormPage extends ModelForm<RACProvider, number> {
></ak-dual-select-dynamic-selected>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("Settings")} name="settings">
<ak-codemirror
<ak-code-editor
mode="yaml"
value="${YAML.stringify(this.instance?.settings ?? {})}"
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">${msg("Connection settings.")}</p>
</ak-form-element-horizontal>
</div>
@@ -4,7 +4,7 @@ import "#admin/providers/rac/RACProviderForm";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#components/ak-status-label";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/buttons/ModalButton";
import "#elements/buttons/SpinnerButton/index";
@@ -2,7 +2,7 @@ import "#admin/providers/RelatedApplicationButton";
import "#admin/providers/radius/RadiusProviderForm";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/buttons/ModalButton";
import "#elements/buttons/SpinnerButton/index";
@@ -404,6 +404,15 @@ export function renderForm({
>
${msg("Transient")}
</option>
<option
value=${SAMLNameIDPolicyEnum.UrnOasisNamesTcSaml11NameidFormatUnspecified}
?selected=${
provider?.defaultNameIdPolicy ===
SAMLNameIDPolicyEnum.UrnOasisNamesTcSaml11NameidFormatUnspecified
}
>
${msg("Unspecified")}
</option>
</select>
<p class="pf-c-form__helper-text">
${msg(
@@ -2,7 +2,7 @@ import "#admin/providers/RelatedApplicationButton";
import "#admin/providers/saml/SAMLProviderForm";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/EmptyState";
import "#elements/Tabs";
import "#elements/buttons/ActionButton/index";
@@ -505,11 +505,11 @@ export class SAMLProviderViewPage extends AKElement {
</ak-action-button>
</div>
<div class="pf-c-card__footer">
<ak-codemirror
<ak-code-editor
mode="xml"
readonly
value="${ifDefined(this.metadata?.metadata)}"
></ak-codemirror>
></ak-code-editor>
</div>
</div>
</div>
@@ -5,7 +5,7 @@ import "#elements/ak-dual-select/ak-dual-select-dynamic-selected-provider";
import "#elements/forms/FormGroup";
import "#elements/forms/HorizontalFormElement";
import "#elements/forms/Radio";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/LicenseNotice";
import "#components/ak-number-input";
import "#elements/utils/TimeDeltaHelp";
@@ -85,8 +85,8 @@ export function renderAuthOAuth(provider?: Partial<SCIMProvider>, _errors: Valid
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("OAuth Parameters")} name="authOauthParams">
<ak-codemirror mode="yaml" value="${YAML.stringify(provider?.authOauthParams ?? {})}">
</ak-codemirror>
<ak-code-editor mode="yaml" value="${YAML.stringify(provider?.authOauthParams ?? {})}">
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Additional OAuth parameters, such as grant_type.")}
</p>
@@ -6,7 +6,7 @@ import "#admin/providers/RelatedApplicationButton";
import "#admin/providers/ssf/StreamTable";
import "#admin/events/ObjectChangelog";
import "#admin/rbac/ObjectPermissionModal";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/EmptyState";
import "#elements/Tabs";
import "#elements/buttons/ModalButton";
@@ -63,6 +63,7 @@ const samlNameIDPolicyAndLabel = [
],
[SAMLNameIDPolicyEnum.UrnOasisNamesTcSaml11NameidFormatX509SubjectName, msg("X509 Subject")],
[SAMLNameIDPolicyEnum.UrnOasisNamesTcSaml20NameidFormatTransient, msg("Transient")],
[SAMLNameIDPolicyEnum.UrnOasisNamesTcSaml11NameidFormatUnspecified, msg("Unspecified")],
];
export interface WSFederationProviderFormProps {
@@ -2,7 +2,7 @@ import "#admin/providers/RelatedApplicationButton";
import "#admin/providers/wsfed/WSFederationProviderForm";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/EmptyState";
import "#elements/Tabs";
import "#elements/buttons/ActionButton/index";
@@ -421,11 +421,11 @@ export class WSFederationProviderViewPage extends AKElement {
</ak-action-button>
</div>
<div class="pf-c-card__footer">
<ak-codemirror
<ak-code-editor
mode="xml"
readonly
value="${ifDefined(this.metadata?.metadata)}"
></ak-codemirror>
></ak-code-editor>
</div>
</div>
</div>
@@ -1,5 +1,5 @@
import "#components/ak-text-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/ak-dual-select/ak-dual-select-provider";
import "#elements/forms/HorizontalFormElement";
import "#elements/Label";
@@ -106,8 +106,8 @@ export class PermissionCheckForm extends ModelForm<PermissionCheck, string> {
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("Expression")} required name="expression">
<ak-codemirror mode="python" value="${ifDefined(this.instance?.expression)}">
</ak-codemirror>
<ak-code-editor mode="python" value="${ifDefined(this.instance?.expression)}">
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Python code defining permission checks.")}
<a
@@ -1,5 +1,5 @@
import "#components/ak-text-input";
import "#elements/CodeMirror/ak-codemirror";
import "#elements/CodeEditor/ak-code-editor";
import "#components/ak-radio-input";
import { aki } from "#common/api/client";
@@ -70,7 +70,7 @@ export class AccessRequestFulfillForm extends WithSession(Form<PatchedGrantReque
<pre>${JSON.stringify(this.request?.requesterData, null, 4)}</pre>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("Data")} name="data">
<ak-codemirror mode="yaml" value="${YAML.stringify({})}"> </ak-codemirror>
<ak-code-editor mode="yaml" value="${YAML.stringify({})}"> </ak-code-editor>
</ak-form-element-horizontal>
`;
}
@@ -6,7 +6,7 @@ import "#admin/rbac/ak-rbac-object-permission-page";
import "#admin/sources/kerberos/KerberosSourceConnectivity";
import "#admin/sources/kerberos/KerberosSourceForm";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/ak-mdx/index";
import "#elements/buttons/ActionButton/index";
@@ -9,7 +9,7 @@ import "#admin/sources/ldap/LDAPSourceUserList";
import "#admin/sources/ldap/LDAPSourceGroupList";
import "#admin/events/ObjectChangelog";
import "#components/sync/SyncStatusCard";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/buttons/ActionButton/index";
import "#elements/buttons/SpinnerButton/index";
@@ -4,7 +4,7 @@ import "#components/ak-secret-textarea-input";
import "#components/ak-slug-input";
import "#components/ak-text-input";
import "#components/ak-switch-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/ak-dual-select/ak-dual-select-dynamic-selected-provider";
import "#elements/forms/FormGroup";
import "#elements/forms/HorizontalFormElement";
@@ -250,11 +250,11 @@ export class OAuthSourceForm extends BaseSourceForm<OAuthSource> {
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("OIDC JWKS")} name="oidcJwks">
<ak-codemirror
<ak-code-editor
mode="javascript"
value="${JSON.stringify(this.instance?.oidcJwks ?? {})}"
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">${msg("Raw JWKS data.")}</p>
</ak-form-element-horizontal>`
: nothing
@@ -2,7 +2,7 @@ import "#admin/policies/BoundPoliciesList";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#admin/sources/oauth/OAuthSourceDiagram";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/buttons/SpinnerButton/index";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
@@ -2,7 +2,7 @@ import "#admin/policies/BoundPoliciesList";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#admin/sources/plex/PlexSourceForm";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/buttons/SpinnerButton/index";
import "#elements/forms/ModalForm";
@@ -358,6 +358,15 @@ export class SAMLSourceForm extends BaseSourceForm<SAMLSource> {
>
${msg("Transient")}
</option>
<option
value=${SAMLNameIDPolicyEnum.UrnOasisNamesTcSaml11NameidFormatUnspecified}
?selected=${
this.instance?.nameIdPolicy ===
SAMLNameIDPolicyEnum.UrnOasisNamesTcSaml11NameidFormatUnspecified
}
>
${msg("Unspecified")}
</option>
</select>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("User path")} name="userPathTemplate">
@@ -2,7 +2,7 @@ import "#admin/policies/BoundPoliciesList";
import "#admin/rbac/ak-rbac-object-permission-page";
import "#admin/sources/saml/SAMLSourceForm";
import "#admin/events/ObjectChangelog";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/Tabs";
import "#elements/buttons/SpinnerButton/index";
import "#elements/forms/ModalForm";
@@ -181,11 +181,11 @@ export class SAMLSourceViewPage extends AKElement {
<div class="pf-l-grid pf-m-gutter">
<div class="pf-c-card pf-l-grid__item pf-m-12-col">
<div class="pf-c-card__body">
<ak-codemirror
<ak-code-editor
mode="xml"
readonly
value="${ifDefined(this.metadata?.metadata)}"
></ak-codemirror>
></ak-code-editor>
</div>
<div class="pf-c-card__footer">
<a
@@ -1,5 +1,5 @@
import "#components/ak-text-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/FormGroup";
import "#elements/forms/HorizontalFormElement";
import PFBanner from "@patternfly/patternfly/components/Banner/banner.css";
@@ -64,10 +64,10 @@ export class AuthenticatorEndpointGDTCStageForm extends BaseStageForm<Authentica
required
name="credentials"
>
<ak-codemirror
<ak-code-editor
mode="javascript"
.value="${this.instance?.credentials ?? {}}"
></ak-codemirror>
></ak-code-editor>
<p class="pf-c-form__helper-text">
${msg("Google Cloud credentials file.")}
</p>
@@ -1,7 +1,7 @@
import "#admin/stages/invitation/InvitationListLink";
import "#components/ak-switch-input";
import "#components/ak-slug-input";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import { aki } from "#common/api/client";
import { PFSize } from "#common/enums";
@@ -179,11 +179,11 @@ export class InvitationForm extends ModelForm<Invitation, string> {
help=${msg("When enabled, the invitation will be deleted after usage.")}
></ak-switch-input>
<ak-form-element-horizontal label=${msg("Custom attributes")} name="fixedData">
<ak-codemirror
<ak-code-editor
mode="yaml"
value="${YAML.stringify(this.instance?.fixedData ?? {})}"
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg(
"Optional data which is loaded into the flow's 'prompt_data' context variable. YAML or JSON.",
+7 -7
View File
@@ -1,4 +1,4 @@
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import "#flow/stages/prompt/PromptStage";
import "#components/ak-switch-input";
@@ -298,14 +298,14 @@ export class PromptForm extends ModelForm<Prompt, string> {
If the evaluation fails, the placeholder itself is returned.`)}
></ak-switch-input>
<ak-form-element-horizontal label=${msg("Placeholder")} name="placeholder">
<ak-codemirror
<ak-code-editor
mode="python"
value="${ifDefined(this.instance?.placeholder)}"
@change=${() => {
this._shouldRefresh = true;
}}
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg(
`Optionally provide a short hint that describes the expected input value.
@@ -325,8 +325,8 @@ export class PromptForm extends ModelForm<Prompt, string> {
If the evaluation fails, the initial value itself is returned.`)}
></ak-switch-input>
<ak-form-element-horizontal label=${msg("Initial value")} name="initialValue">
<ak-codemirror mode="python" value="${ifDefined(this.instance?.initialValue)}">
</ak-codemirror>
<ak-code-editor mode="python" value="${ifDefined(this.instance?.initialValue)}">
</ak-code-editor>
<p class="pf-c-form__helper-text">
${msg(
`Optionally pre-fill the input with an initial value.
@@ -336,14 +336,14 @@ export class PromptForm extends ModelForm<Prompt, string> {
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("Help text")} name="subText">
<ak-codemirror
<ak-code-editor
mode="html"
value="${ifDefined(this.instance?.subText)}"
@change=${() => {
this._shouldRefresh = true;
}}
>
</ak-codemirror>
</ak-code-editor>
<p class="pf-c-form__helper-text">${msg("Any HTML can be used.")}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("Order")} required name="order">
+1 -1
View File
@@ -1,5 +1,5 @@
import "#admin/users/ak-user-group-table";
import "#elements/CodeMirror";
import "#elements/CodeEditor";
import "#elements/forms/HorizontalFormElement";
import "#elements/forms/Radio";
import "#components/ak-text-input";
+2
View File
@@ -0,0 +1,2 @@
export * from "#elements/CodeEditor/ak-code-editor";
export * from "#elements/CodeEditor/shared";
@@ -0,0 +1,122 @@
import "#elements/CodeEditor/ak-code-editor";
import { CodeEditor } from "#elements/CodeEditor/ak-code-editor";
import { afterEach, describe, expect, it, vi } from "vitest";
import { userEvent } from "vitest/browser";
import { html, render } from "lit";
const mounted = new Set<HTMLElement>();
/**
* Render the editor inside a form, the way the admin forms do.
*/
function mount(template: unknown) {
const form = document.body.appendChild(document.createElement("form"));
mounted.add(form);
render(template, form);
return { form, element: form.querySelector<CodeEditor>("ak-code-editor")! };
}
/**
* Wait for the lazily imported editor, then place the cursor at the end of the first line.
*/
async function focusEditor(element: CodeEditor) {
// Vite's dev server transforms Monaco's modules on first import, which takes seconds.
await vi.waitFor(() => expect(element.shadowRoot?.querySelector(".view-lines")).toBeTruthy(), {
timeout: 15_000,
});
await userEvent.click(element.shadowRoot!.querySelector(".view-lines")!);
await userEvent.keyboard("{End}");
}
afterEach(() => {
mounted.forEach((container) => container.remove());
mounted.clear();
});
describe("ak-code-editor", () => {
it("submits the value set on the element before the editor loads", () => {
const { form, element } = mount(
html`<ak-code-editor name="attributes" mode="yaml" value="a: 1"></ak-code-editor>`,
);
expect(new FormData(form).get("attributes")).toBe("a: 1");
expect(element.toJSON()).toStrictEqual({ a: 1 });
});
it("creates the editor once a collapsed group is opened", async () => {
// With the module already loaded, an editor created on connect would render right away.
await import("#elements/CodeEditor/editor");
const { form, element } = mount(
html`<details>
<summary>Advanced settings</summary>
<ak-code-editor mode="yaml" raw value="a: 1"></ak-code-editor>
</details>`,
);
await new Promise((resolve) => setTimeout(resolve, 500));
expect(element.shadowRoot?.querySelector(".monaco-editor")).toBeNull();
form.querySelector("details")!.open = true;
await focusEditor(element);
await userEvent.keyboard("0");
expect(element.value).toBe("a: 10");
});
it("follows typing", async () => {
const { form, element } = mount(
html`<ak-code-editor
name="expression"
mode="python"
raw
value="x = 1"
></ak-code-editor>`,
);
const onChange = vi.fn();
element.addEventListener("change", onChange);
await focusEditor(element);
await userEvent.keyboard("0");
expect(element.value).toBe("x = 10");
expect(new FormData(form).get("expression")).toBe("x = 10");
expect(onChange).toHaveBeenCalled();
});
it("ignores typing when read-only", async () => {
const { element } = mount(
html`<ak-code-editor mode="yaml" raw readonly value="a: 1"></ak-code-editor>`,
);
await focusEditor(element);
await userEvent.keyboard("0");
expect(element.value).toBe("a: 1");
});
it("cuts and pastes with the keyboard", async () => {
const { element } = mount(
html`<ak-code-editor mode="yaml" raw value="a: 1"></ak-code-editor>`,
);
await focusEditor(element);
await userEvent.keyboard("{Shift>}{Home}{/Shift}{ControlOrMeta>}x{/ControlOrMeta}");
expect(element.value).toBe("");
await userEvent.keyboard(
"{ControlOrMeta>}v{/ControlOrMeta}{ControlOrMeta>}v{/ControlOrMeta}",
);
expect(element.value).toBe("a: 1a: 1");
});
});
@@ -0,0 +1,205 @@
import { pluckErrorDetail } from "#common/errors/network";
import type { MonacoEditor } from "#elements/CodeEditor/editor";
import {
CodeEditorMode,
parseCodeEditorSource,
stringifyCodeEditorSource,
} from "#elements/CodeEditor/shared";
import { FormAssociatedElement } from "#elements/forms/form-associated-element";
import type { Jsonifiable } from "type-fest";
import { msg } from "@lit/localize";
import { css, CSSResult, PropertyValues } from "lit";
import { customElement, property } from "lit/decorators.js";
@customElement("ak-code-editor")
export class CodeEditor<T extends Jsonifiable = Jsonifiable> extends FormAssociatedElement<string> {
//#region Styles
public static styles: CSSResult[] = [
css`
:host {
display: block;
/* Holds the field's place until the editor loads. */
min-height: 3rem;
border-radius: var(--pf-global--BorderRadius--sm);
background-color: var(--pf-global--BackgroundColor--light-300);
}
:host([theme="dark"]) {
background-color: #282c34;
}
.ak-c-code-editor {
min-height: 3rem;
max-height: 50vh;
}
`,
];
//#endregion
//#region Properties
@property({ type: String })
public mode: CodeEditorMode = CodeEditorMode.YAML;
@property({ type: Boolean })
public raw?: boolean;
@property()
public set value(nextValue: T) {
if (!nextValue) {
return;
}
this.#source = stringifyCodeEditorSource(nextValue, this.mode);
this.#syncValidity();
// This is only relevant when a value has been set after the editor has been created.
this.#editor?.editor.setValue(this.#source);
}
public get value(): string {
if (typeof this.#source === "undefined") {
return "";
}
return this.#parseSource(this.#source);
}
public toJSON(): string {
return this.value;
}
#syncValidity() {
this.internals.setFormValue(this.#source || "");
let message: string | undefined;
const flags: ValidityStateFlags = {};
if (this.required && !this.#source) {
message = msg("This field is required.");
flags.valueMissing = true;
}
this.internals.setValidity(flags, message, this.#editor?.editor.getDomNode() ?? undefined);
}
//#endregion
//#region Monaco Internals
#editor?: MonacoEditor;
//#region Value State
/**
* The editor's text.
*
* @remarks
* The editor is created once the element is shown, from a lazily imported module,
* so a form submitted before then still reads the value that was set on the element.
*/
#source?: string;
#parseSource(innerValue: string): string {
if (this.raw) {
return innerValue;
}
try {
return parseCodeEditorSource(innerValue, this.mode);
} catch (error: unknown) {
const message = pluckErrorDetail(error);
console.debug("code-editor/parse-error", message);
return innerValue;
}
}
//#endregion
//#region Lifecycle
async #initialize(root: ShadowRoot) {
console.debug("ak-code-editor: initializing editor...");
const { MonacoEditor } = await import("#elements/CodeEditor/editor");
// The element may have been removed while the editor module was loading.
if (!this.isConnected || this.#editor) {
return;
}
this.#editor = new MonacoEditor({
root,
mode: this.mode,
theme: this.activeTheme,
readOnly: this.readOnly || this.disabled,
value: this.#source || "",
onChange: (source) => {
this.#source = source;
this.#syncValidity();
this.dispatchEvent(new Event("change"));
},
});
}
/**
* Defers loading Monaco until the element is shown, since many forms keep their code
* field in a collapsed group that is usually never opened.
*/
#visibilityObserver = new IntersectionObserver((entries) => {
if (!entries.some((entry) => entry.isIntersecting)) return;
this.#visibilityObserver.disconnect();
this.#initialize(this.renderRoot as ShadowRoot);
});
public override connectedCallback(): void {
super.connectedCallback();
this.#visibilityObserver.observe(this);
}
protected override updated(changedProperties: PropertyValues<this>): void {
super.updated(changedProperties);
if (!this.#editor) return;
if (changedProperties.has("mode")) {
this.#editor.setMode(this.mode);
}
if (changedProperties.has("readOnly") || changedProperties.has("disabled")) {
this.#editor.setReadOnly(this.readOnly || this.disabled);
}
}
public override disconnectedCallback(): void {
super.disconnectedCallback();
this.#visibilityObserver.disconnect();
if (this.#editor) {
console.debug("ak-code-editor: destroying editor");
this.#editor.dispose();
this.#editor = undefined;
}
}
//#endregion
}
declare global {
interface HTMLElementTagNameMap {
"ak-code-editor": CodeEditor;
}
}
+226
View File
@@ -0,0 +1,226 @@
/**
* @remarks
* This should be imported dynamically to avoid the bundle size impact of Monaco.
*
* ```ts
* const { MonacoEditor } = await import("#elements/CodeEditor/editor");
* ```
* @file Monaco editor module.
*/
import "monaco-editor/features/bracketMatching/register";
import "monaco-editor/features/caretOperations/register";
import "monaco-editor/features/clipboard/register";
import "monaco-editor/features/comment/register";
import "monaco-editor/features/contextmenu/register";
import "monaco-editor/features/cursorUndo/register";
import "monaco-editor/features/find/register";
import "monaco-editor/features/folding/register";
import "monaco-editor/features/hover/register";
import "monaco-editor/features/gotoLine/register";
import "monaco-editor/features/indentation/register";
import "monaco-editor/features/linesOperations/register";
import "monaco-editor/features/multicursor/register";
import "monaco-editor/features/readOnlyMessage/register";
import "monaco-editor/features/smartSelect/register";
import "monaco-editor/features/snippet/register";
import "monaco-editor/features/toggleTabFocusMode/register";
import "monaco-editor/features/wordHighlighter/register";
import "monaco-editor/features/wordOperations/register";
import "monaco-editor/features/wordPartOperations/register";
import "monaco-editor/languages/definitions/css/register";
import "monaco-editor/languages/definitions/html/register";
import "monaco-editor/languages/definitions/javascript/register";
import "monaco-editor/languages/definitions/python/register";
import "monaco-editor/languages/definitions/xml/register";
import "monaco-editor/languages/definitions/yaml/register";
// The suggestion widget has no feature entry point of its own.
import "monaco-editor/editor/contrib/suggest/browser/suggestController";
// Monaco's package exports do not cover its CSS, so the bundlers alias this path to the file.
import MonacoStyles from "monaco-editor/min/vs/editor/editor.main.css";
import { createStyleSheetUnsafe, setAdoptedStyleSheets } from "#common/stylesheets";
import { ResolvedUITheme, ThemeChangeEvent } from "#common/theme";
import { CodeEditorMode } from "#elements/CodeEditor/shared";
import { OneDark } from "#elements/CodeEditor/themes/one-dark";
import { UiThemeEnum } from "@goauthentik/api";
import { editor as monaco } from "monaco-editor/editor/editor.api";
const $MonacoStyles = createStyleSheetUnsafe(MonacoStyles);
/**
* The rules of Monaco's stylesheet that must apply to the document rather than the editor's
* shadow root:
*
* - Chromium ignores `@font-face` rules in a shadow root's styles, so the icon font only loads when
* the document declares it.
* - Monaco appends its screen reader live region, which announces e.g. search results, to the
* document body. Without the rule that moves it off screen, the announcements are visible below
* the page.
*/
const $MonacoDocumentStyles = new CSSStyleSheet();
for (const rule of $MonacoStyles.cssRules) {
if (
rule instanceof CSSFontFaceRule ||
(rule instanceof CSSStyleRule && rule.selectorText === ".monaco-aria-container")
) {
$MonacoDocumentStyles.insertRule(rule.cssText);
}
}
setAdoptedStyleSheets(document, (currentStyleSheets) => [
...currentStyleSheets,
$MonacoDocumentStyles,
]);
// Keeps the editor apart from the white form behind it, as PatternFly's
// `--pf-global--BackgroundColor--light-300` does for other fields.
// Monaco themes only take literal colors.
monaco.defineTheme("ak-light", {
base: "vs",
inherit: true,
rules: [],
colors: { "editor.background": "#f0f0f0" },
});
monaco.defineTheme("ak-dark", OneDark);
/**
* Language services, loaded with the first editor of their language.
*/
const LanguageServices: Partial<Record<CodeEditorMode, () => Promise<unknown>>> = {
[CodeEditorMode.CSS]: () => import("#elements/CodeEditor/languages/css-service"),
[CodeEditorMode.Python]: () => import("#elements/CodeEditor/languages/python-service"),
};
function loadLanguageService(mode: CodeEditorMode): void {
LanguageServices[mode]?.().catch((error: unknown) => {
console.warn("code-editor: failed to load language service", mode, error);
});
}
/**
* Python is indented by four spaces by convention, and in authentik's documentation.
*/
function tabSize(mode: CodeEditorMode): number {
return mode === CodeEditorMode.Python ? 4 : 2;
}
function themeName(theme: ResolvedUITheme): string {
return theme === UiThemeEnum.Dark ? "ak-dark" : "ak-light";
}
export interface MonacoEditorInit {
mode?: CodeEditorMode;
theme?: ResolvedUITheme;
readOnly?: boolean;
value?: string;
root: ShadowRoot;
onChange?: (value: string) => void;
}
export class MonacoEditor implements Disposable {
public editor: monaco.IStandaloneCodeEditor;
#container = document.createElement("div");
#themeAbortController = new AbortController();
constructor({
mode = CodeEditorMode.JavaScript,
theme = "light",
readOnly = false,
value = "",
onChange = () => {},
root,
}: MonacoEditorInit) {
setAdoptedStyleSheets(root, (currentStyleSheets) =>
currentStyleSheets.includes($MonacoStyles)
? currentStyleSheets
: [...currentStyleSheets, $MonacoStyles],
);
this.#container.className = "ak-c-code-editor";
root.appendChild(this.#container);
this.editor = monaco.create(this.#container, {
value,
language: mode,
theme: themeName(theme),
readOnly,
automaticLayout: true,
minimap: { enabled: false },
wordWrap: "on",
tabSize: tabSize(mode),
// The editor grows with its content, see the content size listener below.
scrollBeyondLastLine: false,
// Let the page scroll once the editor has nothing left to scroll.
scrollbar: { alwaysConsumeMouseWheel: false },
renderLineHighlightOnlyWhenFocus: true,
renderWhitespace: "selection",
guides: { bracketPairs: "active" },
padding: { top: 6, bottom: 6 },
// Word suggestions are computed in a web worker, which is not bundled.
wordBasedSuggestions: "off",
});
loadLanguageService(mode);
// Monaco needs an explicit height. Following the content keeps short values compact,
// and the container's CSS `max-height` caps long ones, which then scroll.
const followContentHeight = () => {
this.#container.style.height = `${this.editor.getContentHeight()}px`;
};
followContentHeight();
this.editor.onDidContentSizeChange(followContentHeight);
// Monaco scrolls its own viewport to reveal a search match or the cursor, which does
// not help while part of the editor is scrolled out of the surrounding form or modal.
// Clicks are left alone, since scrolling the page under the pointer turns them into
// selections.
this.editor.onDidChangeCursorSelection(({ source }) => {
if (source === "mouse") return;
this.#container.scrollIntoView({ block: "nearest" });
});
this.editor.onDidChangeModelContent(() => {
onChange(this.editor.getValue());
});
document.addEventListener(
ThemeChangeEvent.eventName,
(event) => monaco.setTheme(themeName(event.theme)),
{ signal: this.#themeAbortController.signal },
);
}
public setMode(mode: CodeEditorMode): void {
const model = this.editor.getModel();
if (model) {
monaco.setModelLanguage(model, mode);
model.updateOptions({ tabSize: tabSize(mode) });
}
loadLanguageService(mode);
}
public setReadOnly(readOnly: boolean): void {
this.editor.updateOptions({ readOnly });
}
public [Symbol.dispose](): void {
this.#themeAbortController.abort();
this.editor.dispose();
this.#container.remove();
}
public dispose(): void {
this[Symbol.dispose]();
}
}
@@ -0,0 +1,39 @@
/**
* @remarks
* Runs Monaco's CSS language service on the page instead of in a web worker. Its `register`
* entry point would start a worker and, through Monaco's worker setup, load every editor
* feature this package leaves out.
* @file CSS suggestions, hovers and validation.
*/
import { PageWorkerContext } from "#elements/CodeEditor/languages/page-worker";
import { languages } from "monaco-editor/editor/editor.api";
import {
CompletionAdapter,
DiagnosticsAdapter,
FoldingRangeAdapter,
HoverAdapter,
} from "monaco-editor/languages/features/common/lspLanguageFeatures";
import { CSSWorker } from "monaco-editor/languages/features/css/cssWorker";
const service = new CSSWorker(PageWorkerContext, {
languageId: "css",
options: {
validate: true,
data: { useDefaultDataProvider: true },
},
});
const worker = () => Promise.resolve(service);
languages.registerCompletionItemProvider("css", new CompletionAdapter(worker, ["/", "-", ":"]));
languages.registerHoverProvider("css", new HoverAdapter(worker));
languages.registerFoldingRangeProvider("css", new FoldingRangeAdapter(worker));
new DiagnosticsAdapter("css", worker, (listener) => {
// The adapter only checks models created after it, so check the existing ones once.
queueMicrotask(listener);
return { dispose() {} };
});
@@ -0,0 +1,76 @@
/**
* @file Types for the Monaco modules that ship without declarations.
*/
declare module "monaco-editor/editor/contrib/suggest/browser/suggestController" {}
declare module "monaco-editor/languages/features/common/lspLanguageFeatures" {
import type { IDisposable, languages, Uri } from "monaco-editor/editor/editor.api";
/**
* Resolves the language service that answers for the given models.
*/
export type WorkerAccessor<T> = (...uris: Uri[]) => Promise<T>;
export class CompletionAdapter<T> implements languages.CompletionItemProvider {
constructor(worker: WorkerAccessor<T>, triggerCharacters: string[]);
triggerCharacters: string[];
provideCompletionItems: languages.CompletionItemProvider["provideCompletionItems"];
}
export class HoverAdapter<T> implements languages.HoverProvider {
constructor(worker: WorkerAccessor<T>);
provideHover: languages.HoverProvider["provideHover"];
}
export class FoldingRangeAdapter<T> implements languages.FoldingRangeProvider {
constructor(worker: WorkerAccessor<T>);
provideFoldingRanges: languages.FoldingRangeProvider["provideFoldingRanges"];
}
export class DiagnosticsAdapter<T> implements IDisposable {
constructor(
languageId: string,
worker: WorkerAccessor<T>,
configChangeEvent: (listener: () => void) => IDisposable,
);
dispose(): void;
}
}
declare module "monaco-editor/languages/features/css/cssWorker" {
/**
* The model data a language service reads, as Monaco's worker mirrors it.
*/
export interface MirrorModel {
readonly uri: { toString(): string };
readonly version: number;
getValue(): string;
}
export interface CSSWorkerContext {
getMirrorModels(): MirrorModel[];
}
export interface CSSWorkerCreateData {
languageId: "css" | "less" | "scss";
options: {
validate?: boolean;
lint?: Record<string, "ignore" | "warning" | "error">;
data?: { useDefaultDataProvider?: boolean };
};
}
export class CSSWorker {
constructor(ctx: CSSWorkerContext, createData: CSSWorkerCreateData);
}
}
declare module "monaco-editor/languages/definitions/python/python" {
import type { languages } from "monaco-editor/editor/editor.api";
/**
* The Monarch definition Monaco highlights Python with.
*/
export const language: languages.IMonarchLanguage & { keywords: string[] };
}
@@ -0,0 +1,18 @@
/**
* @file Lets Monaco's language services, written to run in a web worker, run on the page.
*/
import { editor } from "monaco-editor/editor/editor.api";
import type { CSSWorkerContext } from "monaco-editor/languages/features/css/cssWorker";
/**
* Gives a language service the editor's models, in place of the copies a worker would hold.
*/
export const PageWorkerContext: CSSWorkerContext = {
getMirrorModels: () =>
editor.getModels().map((model) => ({
uri: model.uri,
version: model.getVersionId(),
getValue: () => model.getValue(),
})),
};
@@ -0,0 +1,95 @@
/**
* @remarks
* Expressions are the body of a function the server wraps them in, so `return` is valid at the
* top level and the context variables are that function's parameters, which are not known here.
* @file Python suggestions.
*/
import { editor, languages, Range } from "monaco-editor/editor/editor.api";
import { language } from "monaco-editor/languages/definitions/python/python";
/**
* The keywords and builtins Monaco highlights, without dunder names such as `__init__`.
*/
const Keywords = Array.from(new Set(language.keywords as string[])).filter(
(keyword) => !keyword.startsWith("__"),
);
const KeywordSet = new Set(Keywords);
const Snippets: Record<string, string> = {
"if": "if ${1:condition}:\n\t${0:pass}",
"if/else": "if ${1:condition}:\n\t${2:pass}\nelse:\n\t${0:pass}",
"for": "for ${1:item} in ${2:items}:\n\t${0:pass}",
"try/except": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:exc}:\n\t${0:pass}",
"def": "def ${1:name}(${2}):\n\t${0:pass}",
"with": "with ${1:expression} as ${2:target}:\n\t${0:pass}",
};
/**
* Names already written in the expression, as Monaco's tokenizer finds them, so names in strings
* and comments are left out.
*/
function collectNames(model: editor.ITextModel, currentWord: string): Set<string> {
const names = new Set<string>();
const lines = model.getLinesContent();
editor.tokenize(model.getValue(), "python").forEach((tokens, lineIndex) => {
const line = lines[lineIndex];
tokens.forEach((token, tokenIndex) => {
if (token.type !== "identifier.python") return;
const end = tokens[tokenIndex + 1]?.offset ?? line.length;
const name = line.slice(token.offset, end);
if (name !== currentWord && !KeywordSet.has(name)) names.add(name);
});
});
return names;
}
languages.registerCompletionItemProvider("python", {
provideCompletionItems(model, position) {
const word = model.getWordUntilPosition(position);
const range = new Range(
position.lineNumber,
word.startColumn,
position.lineNumber,
word.endColumn,
);
// Attribute access needs to know the object's type.
const before = model.getLineContent(position.lineNumber).slice(0, word.startColumn - 1);
if (before.trimEnd().endsWith(".")) return { suggestions: [] };
const { CompletionItemKind: Kind, CompletionItemInsertTextRule: Rule } = languages;
const suggestions: languages.CompletionItem[] = [
...Keywords.map((label) => ({
label,
kind: Kind.Keyword,
insertText: label,
range,
})),
...Object.entries(Snippets).map(([label, insertText]) => ({
label,
kind: Kind.Snippet,
insertText,
insertTextRules: Rule.InsertAsSnippet,
range,
})),
...Array.from(collectNames(model, word.word), (label) => ({
label,
kind: Kind.Variable,
insertText: label,
range,
})),
];
return { suggestions };
},
});
@@ -1,6 +1,9 @@
import { parse as parseYAML, stringify as stringifyYAML } from "yaml";
export const CodeMirrorMode = {
/**
* The languages the code editor highlights, named by their Monaco language ID.
*/
export const CodeEditorMode = {
XML: "xml",
JavaScript: "javascript",
HTML: "html",
@@ -9,11 +12,11 @@ export const CodeMirrorMode = {
YAML: "yaml",
} as const satisfies Record<string, string>;
export type CodeMirrorMode = (typeof CodeMirrorMode)[keyof typeof CodeMirrorMode];
export type CodeEditorMode = (typeof CodeEditorMode)[keyof typeof CodeEditorMode];
//#region Serialization
export function stringifyCodeMirrorSource(value: unknown, mode: CodeMirrorMode): string {
export function stringifyCodeEditorSource(value: unknown, mode: CodeEditorMode): string {
if (typeof value === "string" || value instanceof String) {
return value.toString();
}
@@ -28,11 +31,11 @@ export function stringifyCodeMirrorSource(value: unknown, mode: CodeMirrorMode):
return String(value).toString();
}
export function parseCodeMirrorSource<T = unknown>(value: string, mode: CodeMirrorMode): T {
export function parseCodeEditorSource<T = unknown>(value: string, mode: CodeEditorMode): T {
switch (mode) {
case CodeMirrorMode.YAML:
case CodeEditorMode.YAML:
return parseYAML(value);
case CodeMirrorMode.JavaScript:
case CodeEditorMode.JavaScript:
return JSON.parse(value);
}
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Joshua Azemoh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,505 @@
/**
* @file One Dark theme for Monaco.
* @see https://github.com/azemoh/vscode-onedark (MIT, vendored at 37abe2b, see one-dark.LICENSE)
*/
import type { editor } from "monaco-editor/editor/editor.api";
interface TokenColor {
scope?: string | string[];
settings: { foreground?: string; background?: string; fontStyle?: string };
}
/**
* Monaco's language definitions emit Monarch token names rather than TextMate scopes.
* Each maps to the TextMate scope whose color it takes.
*/
const MonarchScopes: Record<string, string> = {
"number": "constant.numeric",
"tag": "entity.name.tag",
"metatag": "entity.name.tag",
"attribute.name": "entity.other.attribute-name",
"attribute.value": "string",
"type": "entity.name.type",
"namespace": "entity.name.module",
"operators": "keyword.operator",
"regexp": "string.embedded",
};
function toRule(token: string, { foreground, background, fontStyle }: TokenColor["settings"]) {
return {
token,
foreground: foreground?.replace("#", ""),
background: background?.replace("#", ""),
fontStyle,
} satisfies editor.ITokenThemeRule;
}
function createRules(tokenColors: TokenColor[]): editor.ITokenThemeRule[] {
const settingsByScope = new Map<string, TokenColor["settings"]>();
for (const { scope, settings } of tokenColors) {
for (const name of [scope ?? []].flat()) {
// Scope selectors with exclusions have no Monaco equivalent.
if (!name.includes(" ")) settingsByScope.set(name, settings);
}
}
const rules = Array.from(settingsByScope, ([token, settings]) => toRule(token, settings));
for (const [token, scope] of Object.entries(MonarchScopes)) {
const settings = settingsByScope.get(scope);
if (settings) rules.push(toRule(token, settings));
}
return rules;
}
//#region Vendored theme
const OneDarkTheme = {
tokenColors: [
{
settings: {
background: "#282c34",
foreground: "#abb2bf",
findHighlight: "#FFE792",
findHighlightForeground: "#000000",
selectionBorder: "#222218",
activeGuide: "#9D550FB0",
bracketsForeground: "#F8F8F2A5",
bracketsOptions: "underline",
bracketContentsForeground: "#F8F8F2A5",
bracketContentsOptions: "underline",
tagsOptions: "stippled_underline",
},
},
{
name: "Comment",
scope: "comment",
settings: {
foreground: "#5c6370",
fontStyle: "italic",
},
},
{
name: "Comment",
scope: "html.doctype",
settings: {
foreground: "#5c6370",
fontStyle: "italic",
},
},
{
name: "String",
scope: "string",
settings: {
foreground: "#98c379",
},
},
{
name: "Embedded String Begin and End",
scope: ["string.embedded.begin", "string.embedded.end"],
settings: {
foreground: "#e06c75",
},
},
{
name: "Embedded String",
scope: "string.embedded",
settings: {
foreground: "#56b6c2",
},
},
{
name: "Number",
scope: "constant.numeric",
settings: {
foreground: "#d19a66",
},
},
{
name: "Built-in constant",
scope: "constant.language",
settings: {
foreground: "#d19a66",
},
},
{
name: "User-defined constant",
scope: ["constant.character", "constant.other"],
settings: {
foreground: "#d19a66",
},
},
{
name: "Language Variable",
scope: "variable.language",
settings: {
foreground: "#c678dd",
},
},
{
name: "Variable",
scope: ["variable.readwrite", "variable.block", "variable.support"],
settings: {
foreground: "#e06c75",
},
},
{
name: "Variable",
scope: "variable.readwrite.var-single-variable.js",
settings: {
foreground: "#d19a66",
},
},
{
name: "Variable",
scope: "variable.readwrite.js",
settings: {
foreground: "#abb2bf",
},
},
{
name: "Keyword",
scope: [
"keyword",
"keyword.operator.logical",
"keyword.operator.constructor",
"keyword.operator.new",
],
settings: {
foreground: "#c678dd",
},
},
{
name: "Keyword Operator",
scope: "keyword.operator",
settings: {
foreground: "#61afef",
},
},
{
name: "Storage",
scope: "storage",
settings: {
fontStyle: "",
foreground: "#c678dd",
},
},
{
name: "Storage type",
scope: "storage.type.function",
settings: {
foreground: "#c678dd",
},
},
{
name: "Class name",
scope: ["entity.name.class", "entity.name.module", "entity.name.type"],
settings: {
foreground: "#e5c07b",
},
},
{
name: "Inherited class",
scope: "entity.other.inherited-class",
settings: {
foreground: "#98c379",
},
},
{
name: "Tag name",
scope: "entity.name.tag",
settings: {
fontStyle: "",
foreground: "#e06c75",
},
},
{
name: "Tag attribute",
scope: "entity.other.attribute-name",
settings: {
fontStyle: "",
foreground: "#d19a66",
},
},
{
name: "Function name",
scope: "entity.name.function",
settings: {
fontStyle: "",
foreground: "#61afef",
},
},
{
name: "Function argument",
scope: "variable.parameter",
settings: {
fontStyle: "italic",
foreground: "#e06c75",
},
},
{
name: "Function call",
scope: "entity.name.function-call",
settings: {
fontStyle: "",
foreground: "#abb2bf",
},
},
{
name: "Builtin Functions",
scope: ["function.support.builtin", "function.support.core"],
settings: {
fontStyle: "",
foreground: "#56b6c2",
},
},
{
name: "Library function",
scope: "support.function",
settings: {
foreground: "#56b6c2",
},
},
{
name: "Library constant",
scope: "support.constant",
settings: {
fontStyle: "",
foreground: "#e5c07b",
},
},
{
name: "Library class/type",
scope: "support.class",
settings: {
foreground: "#e5c07b",
},
},
{
name: "Library type",
scope: "support.type",
settings: {
foreground: "#e06c75",
},
},
{
name: "Json Property",
scope: "support.dictionary.json",
settings: {
foreground: "#e06c75",
},
},
{
name: "StyleSheet Property name",
scope: [
"support.type.property-name.css",
"support.type.property-name.scss",
"support.type.property-name.less",
"support.type.property-name.sass",
],
settings: {
foreground: "#abb2bf",
},
},
{
name: "StyleSheet Property value",
scope: [
"support.constant.css",
"support.constant.scss",
"support.constant.less",
"support.constant.sass",
],
settings: {
foreground: "#56b6c2",
},
},
{
name: "StyleSheet Variable",
scope: ["variable.css", "variable.scss", "variable.less", "variable.sass"],
settings: {
foreground: "#e06c75",
},
},
{
name: "StyleSheet Variable String",
scope: [
"variable.css.string",
"variable.scss.string",
"variable.less.string",
"variable.sass.string",
],
settings: {
foreground: "#98c379",
},
},
{
name: "StyleSheet Unit",
scope: ["unit.css", "unit.scss", "unit.less", "unit.sass"],
settings: {
foreground: "#d19a66",
},
},
{
name: "StyleSheet Function",
scope: ["function.css", "function.scss", "function.less", "function.sass"],
settings: {
foreground: "#56b6c2",
},
},
{
name: "Other variable",
scope: ["variable.other.property", "variable.other.object", "variable.other.block"],
settings: {
foreground: "#e06c75",
},
},
{
name: "Pug/Jade Import",
scope: ["jade.import.variable", "pug.import.variable"],
settings: {
foreground: "#e06c75",
},
},
{
name: "Invalid",
scope: "invalid",
settings: {
background: "#c678dd",
fontStyle: "",
foreground: "#F8F8F0",
},
},
{
name: "Invalid deprecated",
scope: "invalid.deprecated",
settings: {
background: "#56b6c2",
foreground: "#F8F8F0",
},
},
{
name: "JSON String",
scope: "structure.dictionary.property-name.json",
settings: {
foreground: "#e06c75",
},
},
{
name: "Link",
scope: "string.detected-link",
settings: {
foreground: "#c678dd",
},
},
{
name: "diff.header",
scope: ["meta.diff", "meta.diff.header"],
settings: {
foreground: "#75715E",
},
},
{
name: "diff.deleted",
scope: "markup.deleted",
settings: {
foreground: "#c678dd",
},
},
{
name: "diff.inserted",
scope: "markup.inserted",
settings: {
foreground: "#e5c07b",
},
},
{
name: "diff.changed",
scope: "markup.changed",
settings: {
foreground: "#98c379",
},
},
{
scope: "constant.numeric.line-number.find-in-files - match",
settings: {
foreground: "#56b6c2A0",
},
},
{
scope: "entity.name.filename.find-in-files",
settings: {
foreground: "#98c379",
},
},
],
colors: {
"activityBar.background": "#2F333D",
"activityBar.foreground": "#D7DAE0",
"activityBarBadge.background": "#528bff",
"activityBarBadge.foreground": "#F8FAFD",
"button.background": "#528bff",
"dropdown.background": "#1d1f23",
"diffEditor.insertedTextBackground": "#00809B33",
"dropdown.border": "#181A1F",
"editor.background": "#282c34",
"editorError.foreground": "#c24038",
"editorRuler.foreground": "#484848",
"editor.lineHighlightBackground": "#383E4A",
"editor.selectionBackground": "#3E4451",
"editorCursor.foreground": "#f8f8f0",
"editor.editor.findMatchBackground": "#42557B",
"editor.findMatchHighlightBackground": "#314365",
"editorGroup.background": "#181A1F",
"editorGroup.border": "#181A1F",
"editorGroupHeader.tabsBackground": "#21252B",
"editorIndentGuide.background": "#3B4048",
"editorLineNumber.foreground": "#495162",
"editorWhitespace.foreground": "#3B4048",
"editorHoverWidget.background": "#21252B",
"editorHoverWidget.border": "#181A1F",
"editorSuggestWidget.background": "#21252B",
"editorSuggestWidget.border": "#181A1F",
"editorSuggestWidget.selectedBackground": "#2c313a",
"editorWidget.background": "#21252B",
"input.background": "#1d1f23",
"list.activeSelectionBackground": "#2c313a",
"list.activeSelectionForeground": "#d7dae0",
"list.focusBackground": "#383E4A",
"list.hoverBackground": "#292d35",
"list.highlightForeground": "#C5C5C5",
"list.inactiveSelectionBackground": "#2c313a",
"list.inactiveSelectionForeground": "#d7dae0",
"notification.background": "#21252b",
"scrollbarSlider.background": "#4E566680",
"scrollbarSlider.activeBackground": "#747D9180",
"scrollbarSlider.hoverBackground": "#5A637580",
"sideBar.background": "#21252b",
"sideBarSectionHeader.background": "#282c34",
"statusBar.background": "#21252B",
"statusBar.foreground": "#9da5b4",
"statusBarItem.hoverBackground": "#2c313a",
"statusBar.noFolderBackground": "#21252B",
"statusBar.debuggingBackground": "#21252B",
"tab.activeBackground": "#2c313a",
"tab.border": "#181A1F",
"tab.inactiveBackground": "#21252B",
"titleBar.activeBackground": "#282c34",
"titleBar.activeForeground": "#9da5b4",
"titleBar.inactiveBackground": "#282C34",
"titleBar.inactiveForeground": "#6B717D",
},
name: "One Dark Theme",
};
//#endregion
export const OneDark: editor.IStandaloneThemeData = {
base: "vs-dark",
inherit: true,
rules: createRules(OneDarkTheme.tokenColors),
colors: OneDarkTheme.colors,
};
-2
View File
@@ -1,2 +0,0 @@
export * from "#elements/CodeMirror/ak-codemirror";
export * from "#elements/CodeMirror/shared";
@@ -1,205 +0,0 @@
import { pluckErrorDetail } from "#common/errors/network";
import type { CodeMirrorEditor } from "#elements/CodeMirror/editor";
import {
CodeMirrorMode,
parseCodeMirrorSource,
stringifyCodeMirrorSource,
} from "#elements/CodeMirror/shared";
import { FormAssociatedElement } from "#elements/forms/form-associated-element";
import type { EditorState } from "@codemirror/state";
import type { Jsonifiable } from "type-fest";
import { msg } from "@lit/localize";
import { css, CSSResult } from "lit";
import { customElement, property } from "lit/decorators.js";
@customElement("ak-codemirror")
export class CodeMirrorTextarea<
T extends Jsonifiable = Jsonifiable,
> extends FormAssociatedElement<string> {
//#region Styles
public static styles: CSSResult[] = [
// Better alignment with patternfly components
css`
.cm-editor {
padding-top: calc(
var(--pf-global--spacer--form-element) - var(--pf-global--BorderWidth--sm)
);
padding-bottom: calc(
var(--pf-global--spacer--form-element) - var(--pf-global--BorderWidth--sm)
);
padding-right: var(--pf-c-form-control--inset--base);
padding-left: var(--pf-c-form-control--inset--base);
}
`,
];
//#endregion
//#region Properties
@property({ type: String })
public mode: CodeMirrorMode = CodeMirrorMode.YAML;
@property({ type: Boolean })
public raw?: boolean;
@property()
public set value(nextValue: T) {
if (!nextValue) {
return;
}
this.#parsedValue = stringifyCodeMirrorSource(nextValue, this.mode);
this.#syncValidity();
// This is only relevant when a value has been set after the editor has been created.
this.#editor?.view?.dispatch({
changes: {
from: 0,
to: this.#editor.view?.state.doc.length,
insert: this.#parsedValue,
},
});
}
public get value(): string {
return this.#parse(this.#editor?.view?.state);
}
public toJSON(): string {
return this.value;
}
#syncValidity() {
this.internals.setFormValue(this.#parsedValue || "");
let message: string | undefined;
const flags: ValidityStateFlags = {};
if (this.required && !this.#parsedValue) {
message = msg("This field is required.");
flags.valueMissing = true;
}
this.internals.setValidity(flags, message, this.#editor?.view?.dom);
}
//#endregion
//#region CodeMirror Internals
#editor?: CodeMirrorEditor;
//#region Value State
#parsedValue?: string;
#parse(editorState?: EditorState): string {
if (editorState) {
return this.#parseSource(editorState.doc.toString());
}
// The editor module is imported lazily.
// A form submitted before that import resolves has no editor state to read.
// So we fall back to the pending value stored in `#parsedValue`.
if (typeof this.#parsedValue === "undefined") {
return "";
}
return this.#parseSource(this.#parsedValue);
}
#parseSource(innerValue: string): string {
if (this.raw) {
return innerValue;
}
try {
return parseCodeMirrorSource(innerValue, this.mode);
} catch (error: unknown) {
const message = pluckErrorDetail(error);
console.debug("codemirror/parse-error", message);
return innerValue;
}
}
//#endregion
//#region Lifecycle
async #initialize(root: ShadowRoot | Document) {
console.debug("ak-codemirror: initializing editor...");
const { CodeMirrorEditor } = await import("#elements/CodeMirror/editor");
this.#editor = new CodeMirrorEditor({
root,
mode: this.mode,
theme: this.activeTheme,
readOnly: this.disabled,
value: this.#parsedValue || "",
onUpdate: (view) => {
if (!view.docChanged) {
return;
}
this.#parsedValue = this.#parse(view.state);
this.#syncValidity();
this.dispatchEvent(
new CustomEvent("change", {
detail: view,
}),
);
},
});
this.#editor.view.contentDOM.tabIndex = 0;
root.appendChild(this.#editor.view.dom);
}
public override connectedCallback(): void {
super.connectedCallback();
if (this.getAttribute("tabindex") === null) {
this.setAttribute("tabindex", "0");
}
this.addEventListener("focus", this.#focusListener);
this.role ||= "combobox";
this.#initialize(this.shadowRoot || document);
}
public override disconnectedCallback(): void {
super.disconnectedCallback();
this.removeEventListener("focus", this.#focusListener);
if (this.#editor) {
console.debug("ak-codemirror: destroying editor");
this.#editor.dispose();
}
}
#focusListener = () => {
this.#editor?.view?.contentDOM?.focus();
};
//#endregion
}
declare global {
interface HTMLElementTagNameMap {
"ak-codemirror": CodeMirrorTextarea;
}
}
-141
View File
@@ -1,141 +0,0 @@
/**
* @remarks
* This should be imported dynamically to avoid the bundle size impact of CodeMirror.
*
* ```ts
* const { CodeMirrorEditor } = await import("#elements/CodeMirror/editor");
* ```
* @file CodeMirror editor module.
*/
import { ResolvedUITheme, ThemeChangeEvent } from "#common/theme";
import { CodeMirrorMode } from "#elements/CodeMirror/shared";
import { UiThemeEnum } from "@goauthentik/api";
import { defaultKeymap, history, historyKeymap, indentWithTab } from "@codemirror/commands";
import { css as cssLang } from "@codemirror/lang-css";
import { html as htmlLang } from "@codemirror/lang-html";
import { javascript } from "@codemirror/lang-javascript";
import { python } from "@codemirror/lang-python";
import { xml } from "@codemirror/lang-xml";
import {
defaultHighlightStyle,
LanguageSupport,
StreamLanguage,
syntaxHighlighting,
} from "@codemirror/language";
import * as yamlMode from "@codemirror/legacy-modes/mode/yaml";
import type { Extension } from "@codemirror/state";
import { Compartment, EditorState } from "@codemirror/state";
import { oneDark, oneDarkHighlightStyle } from "@codemirror/theme-one-dark";
import { drawSelection, EditorView, keymap, lineNumbers, ViewUpdate } from "@codemirror/view";
import { match } from "ts-pattern";
//#region Language support
export function createLanguageSupport(mode: CodeMirrorMode): LanguageSupport {
return match(mode)
.with(CodeMirrorMode.XML, () => xml())
.with(CodeMirrorMode.JavaScript, () => javascript())
.with(CodeMirrorMode.HTML, () => htmlLang())
.with(CodeMirrorMode.Python, () => python())
.with(CodeMirrorMode.CSS, () => cssLang())
.with(CodeMirrorMode.YAML, () => new LanguageSupport(StreamLanguage.define(yamlMode.yaml)))
.exhaustive();
}
export interface CodeMirrorInit {
mode?: CodeMirrorMode;
theme?: ResolvedUITheme;
readOnly?: boolean;
value?: string;
root: Document | ShadowRoot;
onUpdate?: (update: ViewUpdate) => void;
}
export class CodeMirrorEditor implements Disposable {
public view: EditorView;
#themeAbortController = new AbortController();
#theme: Compartment = new Compartment();
#syntaxHighlighting: Compartment = new Compartment();
#themeLight = EditorView.theme(
{
"&": {
backgroundColor: "var(--pf-global--BackgroundColor--light-300)",
},
},
{ dark: false },
);
#themeDark = oneDark;
#syntaxHighlightingLight = syntaxHighlighting(defaultHighlightStyle);
#syntaxHighlightingDark = syntaxHighlighting(oneDarkHighlightStyle);
constructor({
mode = CodeMirrorMode.JavaScript,
theme = "light",
readOnly = false,
value = "",
onUpdate = () => {},
root,
}: CodeMirrorInit) {
const dark = theme === UiThemeEnum.Dark;
const extensions: Array<Extension | null> = [
history(),
keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
createLanguageSupport(mode),
lineNumbers(),
drawSelection(),
EditorView.lineWrapping,
EditorView.updateListener.of(onUpdate),
EditorState.readOnly.of(!!readOnly),
EditorState.tabSize.of(2),
this.#syntaxHighlighting.of(
dark ? this.#syntaxHighlightingDark : this.#syntaxHighlightingLight,
),
this.#theme.of(dark ? this.#themeDark : this.#themeLight),
];
this.view = new EditorView({
extensions: extensions.filter(Boolean) as Extension[],
root,
doc: value,
});
document.addEventListener(ThemeChangeEvent.eventName, this.#themeChangeListener, {
signal: this.#themeAbortController.signal,
});
}
#themeChangeListener = (event: ThemeChangeEvent) => {
if (!this.view) {
return;
}
const effects =
event.theme === UiThemeEnum.Dark
? [
this.#theme.reconfigure(this.#themeDark),
this.#syntaxHighlighting.reconfigure(this.#syntaxHighlightingDark),
]
: [
this.#theme.reconfigure(this.#themeLight),
this.#syntaxHighlighting.reconfigure(this.#syntaxHighlightingLight),
];
this.view.dispatch({ effects });
};
public [Symbol.dispose](): void {
this.view.destroy();
}
public dispose(): void {
this[Symbol.dispose]();
}
}
+1 -1
View File
@@ -29,7 +29,7 @@ const NameableElements = new Set([
"INPUT",
"TEXTAREA",
"SELECT",
"AK-CODEMIRROR",
"AK-CODE-EDITOR",
"AK-CHIP-GROUP",
"AK-SEARCH-SELECT",
"AK-RADIO",
+1 -1
View File
@@ -103,7 +103,7 @@ web/src/styles/
authentik/ # component CSS
components/<Name>/ # Per-component overrides or new, unique components
login.css # login-screen layout + token bridges
atom/ # CodeMirror CSS stuff (imported into the CodeMirror component)
atom/ # One Dark syntax colors (imported into ak-mdx)
```
Note: quite a number of components have embedded CSS of their own (via Lit's `css()` function) or
@@ -1,5 +1,5 @@
import "#components/ak-text-input";
import "#elements/CodeMirror/ak-codemirror";
import "#elements/CodeEditor/ak-code-editor";
import "#components/ak-radio-input";
import { aki } from "#common/api/client";
@@ -63,7 +63,7 @@ export class AccessRequestFulfillForm extends Form<PatchedGrantRequestFulfillReq
<pre>${JSON.stringify(this.request?.requesterData, null, 4)}</pre>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${msg("Note")} name="data">
<ak-codemirror mode="yaml" value="${YAML.stringify({})}"> </ak-codemirror>
<ak-code-editor mode="yaml" value="${YAML.stringify({})}"> </ak-code-editor>
</ak-form-element-horizontal>
`;
}
+2 -2
View File
@@ -25,7 +25,7 @@ test.describe("Invitation form", () => {
//#endregion
// Regression for goauthentik/authentik#22637: typing custom attributes into the
// CodeMirror editor must not block submission.
// code editor must not block submission.
test("Create invitation with custom attributes", async ({ page, form, pointer }, testInfo) => {
const name = invitationNames.get(testInfo.testId)!;
const { fill, selectSearchValue } = form;
@@ -33,7 +33,7 @@ test.describe("Invitation form", () => {
const $dialog = page.getByRole("dialog", { name: "New Invitation" });
const $successDialog = page.getByRole("dialog", { name: "Invitation Details" });
const $editor = $dialog.locator("ak-codemirror");
const $editor = $dialog.locator("ak-code-editor");
await test.step("Open the invitation form", async () => {
await expect($dialog, "Form is initially closed").toBeHidden();
+19 -7
View File
@@ -2,7 +2,7 @@
import { join } from "node:path";
import { createBundleDefinitions } from "#bundler/utils/node";
import { createBundleAliases, createBundleDefinitions } from "#bundler/utils/node";
import { inlineCSSPlugin } from "#bundler/vite-plugin-lit-css/node";
import { resolvePackage } from "@goauthentik/core/paths/node";
@@ -12,14 +12,24 @@ import { defineConfig } from "vite";
const patternflyPath = resolvePackage("@patternfly/patternfly", import.meta);
/**
* @satisfies {import("vite").UserConfig["resolve"]}
*/
const resolve = {
alias: [
// `inlineCSSPlugin` appends `?inline` to CSS imports, which a string alias won't match.
...Object.entries(createBundleAliases()).map(([find, replacement]) => ({
find: new RegExp(`^${RegExp.escape(find)}(?=\\?|$)`),
replacement,
})),
{ find: "./assets/fonts", replacement: join(patternflyPath, "assets", "fonts") },
{ find: "./assets/pficon", replacement: join(patternflyPath, "assets", "pficon") },
],
};
export default defineConfig({
define: createBundleDefinitions(),
resolve: {
alias: {
"./assets/fonts": join(patternflyPath, "assets", "fonts"),
"./assets/pficon": join(patternflyPath, "assets", "pficon"),
},
},
resolve,
optimizeDeps: {
// Fixes dependency resolution issue associated with `npm link`ed packages.
include: ["@goauthentik/api"],
@@ -66,6 +76,8 @@ export default defineConfig({
// this the CSS resolves to a Vite style side-effect with no
// default export, and importing any AKElement throws.
plugins: [inlineCSSPlugin()],
// Nor the root aliases, which the code editor needs for Monaco's stylesheet.
resolve,
test: {
setupFiles: ["./test/lit/setup.js"],
@@ -169,6 +169,7 @@ In authentik, it's also possible to configure the default SAML NameID policy use
| Windows - `urn:oasis:names:tc:SAML:2.0:nameid-format:WindowsDomainQualifiedName` | NameID will be set to the user's UPN. This is also set by the LDAP source, and also falls back to the persistent identifier. |
| Transient - `urn:oasis:names:tc:SAML:2.0:nameid-format:transient` | NameID will be set based on the user's session ID. |
| Email address - `urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress` | NameID will be set to the user's email address. |
| Unspecified - `urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified` | No default is applied. NameID will be set based on the policy requested by the SP; if the SP does not request one, it falls back to the persistent identifier. |
:::warning Email based NameID attribute
By default, users are free to change their email addresses. Therefore, it is recommended to either: avoid using a user's email address as the NameID attribute or, if possible, disallow changing email addresses.
@@ -0,0 +1,131 @@
---
title: Integrate with Google Cloud Workforce Identity Federation
sidebar_label: Google Cloud Workforce Identity Federation
support_level: community
---
## What is Google Cloud Workforce Identity Federation?
> Workforce Identity Federation lets you use your external IdP to authenticate your workforce—users and groups of users, such as employees, partners, and contractors. Users can then access Google Cloud using single sign-on (SSO), through your IdP.
>
> -- https://docs.cloud.google.com/iam/docs/workforce-identity-federation
This guide configures authentik as a SAML identity provider for a Google Cloud workforce identity pool, and uses authentik group membership to grant access to Google Cloud resources through IAM.
## Preparation
The following placeholders are used in this guide:
- `authentik.company` is the FQDN of the authentik installation.
Before you start, choose an ID for the workforce identity pool. Pool IDs must be globally unique. This guide refers to it as `<pool_id>`, and uses `authentik` as the ID of the provider in that pool.
To complete this guide, you need:
- A Google Cloud organization with [Essential Contacts](https://docs.cloud.google.com/resource-manager/docs/managing-notification-contacts) configured.
- The **IAM Workforce Pool Admin** (`roles/iam.workforcePoolAdmin`) role on the organization, and the **Project IAM Admin** (`roles/resourcemanager.projectIamAdmin`) role on the project, or equivalent permissions.
- The [Google Cloud CLI](https://docs.cloud.google.com/sdk/docs/install-sdk), installed and initialized.
- An authentik group named `gcp-readers` that contains the users who should have access to Google Cloud. If you use a different group name, use it everywhere this guide uses `gcp-readers`.
:::info
This documentation lists only the settings that you need to change from their default values. Be aware that any changes other than those explicitly mentioned in this guide could cause issues accessing your application.
:::
:::info Google Workspace and Cloud Identity
Workforce Identity Federation does not create Google accounts. To sign in to Google Workspace, or to Google Cloud with Cloud Identity accounts, see [Integrate with Google Workspace](../google/index.mdx).
:::
## authentik configuration
To support the integration of Google Cloud Workforce Identity Federation with authentik, you need to create an [application/provider pair](/docs/add-secure-apps/applications/manage_apps/#create-an-application-and-provider-pair) in authentik.
### Create an application and provider in authentik
1. Log in to authentik as an administrator and open the authentik Admin interface.
2. Navigate to **Applications** > **Applications** and click **New Application** to open the application wizard.
- **Application**: provide a descriptive name, an optional group for the type of application, the policy engine mode, and optional UI settings.
- Under **UI settings**, set **Launch URL** to `https://auth.cloud.google/signin/locations/global/workforcePools/<pool_id>/providers/authentik?continueUrl=https://console.cloud.google/`.
- **Choose a Provider type**: select **SAML Provider** as the provider type.
- **Configure the Provider**: provide a name (or accept the auto-provided name), the authorization flow to use for this provider, and the following required configurations.
- Set **ACS URL** to `https://auth.cloud.google/signin-callback/locations/global/workforcePools/<pool_id>/providers/authentik`.
- Set **Audience** to `https://iam.googleapis.com/locations/global/workforcePools/<pool_id>/providers/authentik`.
- Under **Advanced protocol settings**:
- Select an available **Signing Certificate**.
- Enable **Sign responses**.
- Set **NameID Property Mapping** to `authentik default SAML Mapping: User ID`.
- Set **Service Provider Binding** to **Post**.
- **Configure Bindings** _(optional)_: you can create a [binding](/docs/add-secure-apps/bindings-overview/) (policy, group, or user) to manage the listing and access to applications on a user's **Application Dashboard** page. Bind the `gcp-readers` group to show the application only to its members.
3. Click **Submit** to save the new application and provider.
:::info User identifier
Google Cloud uses the SAML NameID as the user's subject (`google.subject`) and includes it in IAM principal identifiers and audit logs. Avoid changing the **NameID Property Mapping** after users have signed in, because a different NameID is treated as a different user.
:::
### Download the metadata file
1. Navigate to **Applications** > **Providers** and click the name of the provider that you created.
2. Under **Related objects** > **Metadata**, click **Download**. This metadata file is required in the next section.
## Google Cloud configuration
To support the integration of authentik with Google Cloud, create a workforce identity pool and a SAML provider that trusts authentik, and then grant the authentik group access to your resources.
### Create a workforce identity pool
Run the following command to create the workforce identity pool, replacing `<organization_id>` with your Google Cloud organization ID:
```bash
gcloud iam workforce-pools create "<pool_id>" \
--organization="<organization_id>" \
--display-name="authentik" \
--location=global
```
If the command fails with a permission error shortly after you were granted the IAM Workforce Pool Admin role, wait a few minutes for the [role grant to propagate](https://docs.cloud.google.com/iam/docs/access-change-propagation) and try again.
### Create the SAML provider
Run the following command to create the SAML provider, replacing `<path_to_metadata_file>` with the path to the metadata file that you downloaded from authentik:
```bash
gcloud iam workforce-pools providers create-saml "authentik" \
--workforce-pool="<pool_id>" \
--display-name="authentik" \
--idp-metadata-path="<path_to_metadata_file>" \
--attribute-mapping="google.subject=assertion.subject,google.groups=assertion.attributes['http://schemas.xmlsoap.org/claims/Group']" \
--attribute-condition="'gcp-readers' in google.groups" \
--location=global
```
The attribute mapping sets `google.subject` to the SAML NameID and `google.groups` to the authentik groups sent by the `authentik default SAML Mapping: Groups` property mapping. The attribute condition only allows members of the `gcp-readers` group to sign in through this provider.
### Grant access to a project
Grant IAM roles to the `gcp-readers` group on the resources that its members need to access. For example, the following commands grant the **Browser** and **Compute Viewer** roles on a project, where `<project_id>` is the ID of the project:
```bash
gcloud projects add-iam-policy-binding "<project_id>" \
--member="principalSet://iam.googleapis.com/locations/global/workforcePools/<pool_id>/group/gcp-readers" \
--role="roles/browser"
gcloud projects add-iam-policy-binding "<project_id>" \
--member="principalSet://iam.googleapis.com/locations/global/workforcePools/<pool_id>/group/gcp-readers" \
--role="roles/compute.viewer"
```
:::info Federated console
Workforce Identity Federation users sign in to the federated Google Cloud console, which supports a subset of Google Cloud products. Refer to [Supported products and limitations](https://docs.cloud.google.com/iam/docs/federated-identity-supported-services) before granting access to a service.
:::
## Configuration verification
To confirm that authentik is properly configured with Google Cloud Workforce Identity Federation, log in to authentik as a member of the `gcp-readers` group and open the Google Cloud application from the authentik User interface. The federated Google Cloud console should open. Select the project and confirm that the user can access the resources that their IAM roles allow.
If Google Cloud shows `The given credential is rejected by the attribute condition`, confirm that the user is a member of `gcp-readers` and that the provider's **Property mappings** include `authentik default SAML Mapping: Groups`.
## Resources
- [Google Cloud documentation - Workforce Identity Federation](https://docs.cloud.google.com/iam/docs/workforce-identity-federation)
- [Google Cloud documentation - Configure Workforce Identity Federation](https://docs.cloud.google.com/iam/docs/configuring-workforce-identity-federation)
- [Google Cloud documentation - Set up user access to the federated console](https://docs.cloud.google.com/iam/docs/workforce-console-sso)
- [Google Cloud documentation - Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access)
Loaded 100 of 101 files, more files were not shown because too many files have changed in this diff. Show more