Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions authentik/core/api/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ def check_access(self, request: Request, slug: str) -> Response:

@extend_schema(
parameters=[
OpenApiParameter(
name="superuser_full_list",
location=OpenApiParameter.QUERY,
type=OpenApiTypes.BOOL,
),
OpenApiParameter(
name="for_user",
location=OpenApiParameter.QUERY,
Expand All @@ -229,18 +224,16 @@ def check_access(self, request: Request, slug: str) -> Response:
location=OpenApiParameter.QUERY,
type=OpenApiTypes.BOOL,
),
]
],
responses={
200: ApplicationSerializer(many=True),
}
)
def list(self, request: Request) -> Response:
"""Custom list method that checks Policy based access instead of guardian"""
@action(methods=["GET"], detail=False)
def accessible(self, request: Request) -> Response:
"""Get applications accessible for user"""
should_cache = request.query_params.get("search", "") == ""

superuser_full_list = (
str(request.query_params.get("superuser_full_list", "false")).lower() == "true"
)
if superuser_full_list and request.user.is_superuser:
return super().list(request)

only_with_launch_url = str(
request.query_params.get("only_with_launch_url", "false")
).lower()
Expand Down
67 changes: 54 additions & 13 deletions schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2631,12 +2631,8 @@ paths:
/core/applications/:
get:
operationId: core_applications_list
description: Custom list method that checks Policy based access instead of guardian
description: Application Viewset
parameters:
- in: query
name: for_user
schema:
type: integer
- in: query
name: group
schema:
Expand All @@ -2654,10 +2650,6 @@ paths:
schema:
type: string
- $ref: '#/components/parameters/QueryName'
- in: query
name: only_with_launch_url
schema:
type: boolean
- $ref: '#/components/parameters/QueryPaginationOrdering'
- $ref: '#/components/parameters/QueryPaginationPage'
- $ref: '#/components/parameters/QueryPaginationPageSize'
Expand All @@ -2666,10 +2658,6 @@ paths:
name: slug
schema:
type: string
- in: query
name: superuser_full_list
schema:
type: boolean
tags:
- core
security:
Expand Down Expand Up @@ -2930,6 +2918,59 @@ paths:
$ref: '#/components/responses/ValidationErrorResponse'
'403':
$ref: '#/components/responses/GenericErrorResponse'
/core/applications/accessible/:
get:
operationId: core_applications_accessible_list
description: Get applications accessible for user
parameters:
- in: query
name: for_user
schema:
type: integer
- in: query
name: group
schema:
type: string
- in: query
name: meta_description
schema:
type: string
- in: query
name: meta_launch_url
schema:
type: string
- in: query
name: meta_publisher
schema:
type: string
- $ref: '#/components/parameters/QueryName'
- in: query
name: only_with_launch_url
schema:
type: boolean
- $ref: '#/components/parameters/QueryPaginationOrdering'
- $ref: '#/components/parameters/QueryPaginationPage'
- $ref: '#/components/parameters/QueryPaginationPageSize'
- $ref: '#/components/parameters/QuerySearch'
- in: query
name: slug
schema:
type: string
tags:
- core
security:
- authentik: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedApplicationList'
description: ''
'400':
$ref: '#/components/responses/ValidationErrorResponse'
'403':
$ref: '#/components/responses/GenericErrorResponse'
/core/authenticated_sessions/:
get:
operationId: core_authenticated_sessions_list
Expand Down
1 change: 0 additions & 1 deletion web/src/admin/applications/ApplicationListPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export class ApplicationListPage extends WithBrandConfig(TablePage<Application>)
async apiEndpoint(): Promise<PaginatedResponse<Application>> {
return new CoreApi(DEFAULT_CONFIG).coreApplicationsList({
...(await this.defaultEndpointConfig()),
superuserFullList: true,
});
}

Expand Down
1 change: 0 additions & 1 deletion web/src/admin/brands/BrandForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export class BrandForm extends ModelForm<Brand, string> {
.fetchObjects=${async (query?: string): Promise<Application[]> => {
const args: CoreApplicationsListRequest = {
ordering: "name",
superuserFullList: true,
};
if (query !== undefined) {
args.search = query;
Expand Down
2 changes: 1 addition & 1 deletion web/src/admin/users/UserApplicationTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class UserApplicationTable extends Table<Application> {
static styles: CSSResult[] = [...super.styles, applicationListStyle];

async apiEndpoint(): Promise<PaginatedResponse<Application>> {
return new CoreApi(DEFAULT_CONFIG).coreApplicationsList({
return new CoreApi(DEFAULT_CONFIG).coreApplicationsAccessibleList({
...(await this.defaultEndpointConfig()),
forUser: this.user?.pk,
});
Expand Down
4 changes: 2 additions & 2 deletions web/src/user/LibraryPage/ak-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ export class LibraryPage extends AKElement {
onlyWithLaunchUrl: true,
});

const applicationListFetch = await coreApi().coreApplicationsList(applicationListParams(1));
const applicationListFetch = await coreApi().coreApplicationsAccessibleList(applicationListParams(1));
const pageCount = applicationListFetch.pagination.totalPages;
if (pageCount === 1) {
return applicationListFetch.results;
}

const applicationLaterPages = await Promise.allSettled(
Array.from({ length: pageCount - 1 }).map((_a, idx) =>
coreApi().coreApplicationsList(applicationListParams(idx + 2)),
coreApi().coreApplicationsAccessibleList(applicationListParams(idx + 2)),
),
);

Expand Down
Loading