Skip to content

Commit

Permalink
Match path correctly, PR enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaHeiligers committed Mar 1, 2023
1 parent ac5eb63 commit 30e903b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class CoreKibanaRequest<
private getAccess(request: RawRequest): 'internal' | 'public' {
return (
((request.route?.settings as RouteOptions)?.app as KibanaRouteOptions)?.access ??
(request.path.includes('internal') ? 'internal' : 'public')
(request.path.startsWith('/internal') ? 'internal' : 'public')
);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/http/core-http-server/src/router/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ export interface RouteConfigOptions<Method extends RouteMethod> {
xsrfRequired?: Method extends 'get' ? never : boolean;

/**
* Defines access permission for a route
* Defines intended request origin of the route:
* - public. The route is public, declared stable and intended for external access.
* In the future, may require an incomming request to contain a specified header.
* - internal. The route is internal and intended for internal access only.
*
* If not declared, infers access from route path:
* - access =`internal` for '/internal' route path prefix
* - access = `public` for '/api' route path prefix
* - access = `public` for everything else
*/
access?: 'public' | 'internal';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,13 @@ export interface VersionHTTPToolkit {
): VersionedRouter<Ctx>;
}

type WithRequiredProperty<Type, Key extends keyof Type> = Type & {
[Property in Key]-?: Type[Property];
};

/**
* Versioned route access flag, required
* - '/api/foo' is 'public'
* - '/internal/my-foo' is 'internal'
* Required
*/
type VersionedRouteConfigOptions = WithRequiredProperty<RouteConfigOptions<RouteMethod>, 'access'>;
type VersionedRouteConfigOptions = Required<Pick<RouteConfigOptions<RouteMethod>, 'access'>>;
/**
* Configuration for a versioned route
* @experimental
Expand Down

0 comments on commit 30e903b

Please sign in to comment.