Compare commits
8 Commits
enterprise
...
sources/oa
Author | SHA1 | Date | |
---|---|---|---|
a6b072369b | |||
c85471575a | |||
5d00dc7e9e | |||
6982e7d1c9 | |||
c67188aee2 | |||
16a5c37cbd | |||
b25e7877c3 | |||
6c68068551 |
@ -6,7 +6,7 @@ from djangoql.ast import Name
|
|||||||
from djangoql.exceptions import DjangoQLError
|
from djangoql.exceptions import DjangoQLError
|
||||||
from djangoql.queryset import apply_search
|
from djangoql.queryset import apply_search
|
||||||
from djangoql.schema import DjangoQLSchema
|
from djangoql.schema import DjangoQLSchema
|
||||||
from rest_framework.filters import SearchFilter
|
from rest_framework.filters import BaseFilterBackend, SearchFilter
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
@ -39,19 +39,21 @@ class BaseSchema(DjangoQLSchema):
|
|||||||
return super().resolve_name(name)
|
return super().resolve_name(name)
|
||||||
|
|
||||||
|
|
||||||
class QLSearch(SearchFilter):
|
class QLSearch(BaseFilterBackend):
|
||||||
"""rest_framework search filter which uses DjangoQL"""
|
"""rest_framework search filter which uses DjangoQL"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self._fallback = SearchFilter()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def enabled(self):
|
def enabled(self):
|
||||||
return apps.get_app_config("authentik_enterprise").enabled()
|
return apps.get_app_config("authentik_enterprise").enabled()
|
||||||
|
|
||||||
def get_search_terms(self, request) -> str:
|
def get_search_terms(self, request: Request) -> str:
|
||||||
"""
|
"""Search terms are set by a ?search=... query parameter,
|
||||||
Search terms are set by a ?search=... query parameter,
|
and may be comma and/or whitespace delimited."""
|
||||||
and may be comma and/or whitespace delimited.
|
params = request.query_params.get("search", "")
|
||||||
"""
|
|
||||||
params = request.query_params.get(self.search_param, "")
|
|
||||||
params = params.replace("\x00", "") # strip null characters
|
params = params.replace("\x00", "") # strip null characters
|
||||||
return params
|
return params
|
||||||
|
|
||||||
@ -70,9 +72,9 @@ class QLSearch(SearchFilter):
|
|||||||
search_query = self.get_search_terms(request)
|
search_query = self.get_search_terms(request)
|
||||||
schema = self.get_schema(request, view)
|
schema = self.get_schema(request, view)
|
||||||
if len(search_query) == 0 or not self.enabled:
|
if len(search_query) == 0 or not self.enabled:
|
||||||
return super().filter_queryset(request, queryset, view)
|
return self._fallback.filter_queryset(request, queryset, view)
|
||||||
try:
|
try:
|
||||||
return apply_search(queryset, search_query, schema=schema)
|
return apply_search(queryset, search_query, schema=schema)
|
||||||
except DjangoQLError as exc:
|
except DjangoQLError as exc:
|
||||||
LOGGER.debug("Failed to parse search expression", exc=exc)
|
LOGGER.debug("Failed to parse search expression", exc=exc)
|
||||||
return super().filter_queryset(request, queryset, view)
|
return self._fallback.filter_queryset(request, queryset, view)
|
||||||
|
@ -57,7 +57,7 @@ class QLTest(APITestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual(res.status_code, 200)
|
self.assertEqual(res.status_code, 200)
|
||||||
content = loads(res.content)
|
content = loads(res.content)
|
||||||
self.assertGreaterEqual(content["pagination"]["count"], 1)
|
self.assertEqual(content["pagination"]["count"], 1)
|
||||||
self.assertEqual(content["results"][0]["username"], self.user.username)
|
self.assertEqual(content["results"][0]["username"], self.user.username)
|
||||||
|
|
||||||
def test_search_json(self):
|
def test_search_json(self):
|
||||||
|
@ -232,12 +232,12 @@ class GoogleOAuthSource(CreatableType, OAuthSource):
|
|||||||
|
|
||||||
|
|
||||||
class AzureADOAuthSource(CreatableType, OAuthSource):
|
class AzureADOAuthSource(CreatableType, OAuthSource):
|
||||||
"""Social Login using Azure AD."""
|
"""Social Login using Entra ID."""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
verbose_name = _("Azure AD OAuth Source")
|
verbose_name = _("Entra ID OAuth Source")
|
||||||
verbose_name_plural = _("Azure AD OAuth Sources")
|
verbose_name_plural = _("Entra ID OAuth Sources")
|
||||||
|
|
||||||
|
|
||||||
class OpenIDConnectOAuthSource(CreatableType, OAuthSource):
|
class OpenIDConnectOAuthSource(CreatableType, OAuthSource):
|
||||||
|
@ -73,9 +73,7 @@ class AzureADType(SourceType):
|
|||||||
authorization_url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
|
authorization_url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
|
||||||
access_token_url = "https://login.microsoftonline.com/common/oauth2/v2.0/token" # nosec
|
access_token_url = "https://login.microsoftonline.com/common/oauth2/v2.0/token" # nosec
|
||||||
profile_url = "https://graph.microsoft.com/v1.0/me"
|
profile_url = "https://graph.microsoft.com/v1.0/me"
|
||||||
oidc_well_known_url = (
|
oidc_well_known_url = None
|
||||||
"https://login.microsoftonline.com/common/.well-known/openid-configuration"
|
|
||||||
)
|
|
||||||
oidc_jwks_url = "https://login.microsoftonline.com/common/discovery/keys"
|
oidc_jwks_url = "https://login.microsoftonline.com/common/discovery/keys"
|
||||||
|
|
||||||
authorization_code_auth_method = AuthorizationCodeAuthMethod.POST_BODY
|
authorization_code_auth_method = AuthorizationCodeAuthMethod.POST_BODY
|
||||||
|
File diff suppressed because one or more lines are too long
@ -478,8 +478,10 @@ export abstract class Table<T> extends WithLicenseSummary(AKElement) implements
|
|||||||
renderSearch(): TemplateResult {
|
renderSearch(): TemplateResult {
|
||||||
const runSearch = (value: string) => {
|
const runSearch = (value: string) => {
|
||||||
this.search = value;
|
this.search = value;
|
||||||
|
this.page = 1;
|
||||||
updateURLParams({
|
updateURLParams({
|
||||||
search: value,
|
search: value,
|
||||||
|
tablePage: 1,
|
||||||
});
|
});
|
||||||
this.fetch();
|
this.fetch();
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@ import { updateURLParams } from "#elements/router/RouteMatch";
|
|||||||
import { Table } from "#elements/table/Table";
|
import { Table } from "#elements/table/Table";
|
||||||
|
|
||||||
import { msg } from "@lit/localize";
|
import { msg } from "@lit/localize";
|
||||||
import { CSSResult } from "lit";
|
import { CSSResult, nothing } from "lit";
|
||||||
import { TemplateResult, html } from "lit";
|
import { TemplateResult, html } from "lit";
|
||||||
import { ifDefined } from "lit/directives/if-defined.js";
|
import { ifDefined } from "lit/directives/if-defined.js";
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ export abstract class TablePage<T> extends Table<T> {
|
|||||||
: html`<ak-empty-state icon=${this.pageIcon()}
|
: html`<ak-empty-state icon=${this.pageIcon()}
|
||||||
><span>${msg("No objects found.")}</span>
|
><span>${msg("No objects found.")}</span>
|
||||||
<div slot="body">
|
<div slot="body">
|
||||||
${this.searchEnabled() ? this.renderEmptyClearSearch() : html``}
|
${this.searchEnabled() ? this.renderEmptyClearSearch() : nothing}
|
||||||
</div>
|
</div>
|
||||||
<div slot="primary">${this.renderObjectCreate()}</div>
|
<div slot="primary">${this.renderObjectCreate()}</div>
|
||||||
</ak-empty-state>`}
|
</ak-empty-state>`}
|
||||||
@ -61,8 +61,10 @@ export abstract class TablePage<T> extends Table<T> {
|
|||||||
this.search = "";
|
this.search = "";
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
this.fetch();
|
this.fetch();
|
||||||
|
this.page = 1;
|
||||||
updateURLParams({
|
updateURLParams({
|
||||||
search: "",
|
search: "",
|
||||||
|
tablePage: 1,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
class="pf-c-button pf-m-link"
|
class="pf-c-button pf-m-link"
|
||||||
|
Reference in New Issue
Block a user