Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/gateway services #630

Merged
merged 36 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6625220
First pass at laying out services page
Jonesy Oct 13, 2022
20fd0b6
Add nested metrics table row
Jonesy Oct 13, 2022
d3493b4
Wire up metrics details
Jonesy Oct 14, 2022
9d33075
Finish basic styling of metrics
Jonesy Oct 17, 2022
81ff89b
Add lazy loading metrics
Jonesy Oct 21, 2022
af33e91
Add new queries
Jonesy Oct 21, 2022
43cb6d0
Handle empty view
Jonesy Oct 21, 2022
19da2b8
Add search to services list
Jonesy Oct 21, 2022
b73d4da
Add missing service query
Jonesy Oct 24, 2022
024fec3
Fix type issues, add filters
Jonesy Oct 25, 2022
0116956
Update query
Jonesy Oct 25, 2022
4000c64
Add missing line break
Jonesy Oct 25, 2022
2afc136
Fix a query
Jonesy Oct 25, 2022
130dbf8
Fix rounding error, graphql item
Jonesy Oct 26, 2022
25265a7
Remove days from query
Jonesy Oct 26, 2022
9dc22f6
Fix nested metrics
Jonesy Oct 26, 2022
b2f1a6e
Add testid
Jonesy Oct 27, 2022
62b657d
add metrics test ids
Jonesy Oct 28, 2022
4fd3611
Tidy up styles and empty states
Jonesy Oct 28, 2022
9187db9
Add test ids for details
Jonesy Oct 31, 2022
dc1b08e
Fix type error
Jonesy Oct 31, 2022
1092bb4
Tidy up routes, add scrolling for long lists
Jonesy Oct 31, 2022
c7b64de
Fix some table prop spreading
Jonesy Oct 31, 2022
8d4a7f2
Better error handling, other UI feedback
Jonesy Nov 2, 2022
fa4890d
Add plugins to filters, fix search logic
Jonesy Nov 4, 2022
1b2e948
Fix allowed queries
Jonesy Nov 4, 2022
14b12f2
Update mocks for gs
Jonesy Nov 4, 2022
3d8871f
Remove duplicate query keys
Jonesy Nov 4, 2022
8df1b8f
Fix type errors
Jonesy Nov 4, 2022
748d05f
Add missing query
Jonesy Nov 8, 2022
cf0a191
Add missing line in query
Jonesy Nov 8, 2022
cdfac58
Fix plugin options
Jonesy Nov 11, 2022
3dbda86
Add environments to example data
Jonesy Nov 16, 2022
6a1bcae
limit plugin list
ikethecoder Nov 22, 2022
9b143e5
limit plugin list inc types
ikethecoder Nov 22, 2022
6d7c6e9
add namespace filtering to queries for services and metrics
ikethecoder Nov 22, 2022
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
10 changes: 10 additions & 0 deletions src/authz/actions/filterByServiceNS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const filterByServiceNS = (context, value) => {
const namespace = context['user']['namespace'];
if (process.env.RULE_DEBUG) {
console.log('Action: Filter By Service NS' + namespace);
}

return { service: { namespace: namespace } };
};

module.exports = filterByServiceNS;
1 change: 1 addition & 0 deletions src/authz/enforcement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const actions: any = {
filterBySelf: require('./actions/filterBySelf'),
filterByRequestor: filterByRequestor,
filterByPackageNS: require('./actions/filterByPackageNS'),
filterByServiceNS: require('./actions/filterByServiceNS'),
filterByProductNSOrActiveEnvironment: require('./actions/filterByProductNSOrActiveEnvironment'),
filterByTemporaryIdentity: require('./actions/filterByTemporaryIdentity'),
filterByUserNS: require('./actions/filterByUserNS'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

query GetMetrics($service: String!, $days: [String!]) {
allMetrics(
sortBy: day_ASC
where: {query: "kong_http_requests_hourly_service", day_in: $days, service: {name_contains: $service}}
) {
query
day
metric
values
service {
name
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

query GetFilterConsumers($namespace: String!) {
allProductsByNamespace(where: {namespace: $namespace}) {
name
id
environments {
id
name
}
}
allConsumerScopesAndRoles
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

query GetServices($days: [String!]) {
allGatewayServicesByNamespace(first: 200) {
id
name
updatedAt
environment {
id
name
active
flow
product {
id
name
organization {
title
}
organizationUnit {
title
}
}
}
routes {
id
name
}
plugins {
id
name
}
}
allMetrics(
sortBy: day_ASC
where: { query: "kong_http_requests_hourly_namespace", day_in: $days }
) {
query
day
metric
values
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

query GetGatewayService($id: ID!) {
GatewayService(where: { id: $id }) {
id
name
namespace
tags
host
environment {
id
name
active
flow
product {
name
organization {
title
}
organizationUnit {
title
}
}
}
plugins {
id
name
}
routes {
id
name
hosts
paths
methods
}
updatedAt
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

query GetGatewayService($id: ID!) {
GatewayService(where: {id: $id}) {
id
name
namespace
tags
host
environment {
id
name
active
flow
product {
name
organization {
title
}
organizationUnit {
title
}
}
}
plugins {
id
name
}
routes {
id
name
hosts
paths
methods
}
updatedAt
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

query GetGatewayServiceFilters($namespace: String!) {
allGatewayPluginsByNamespace {
id
name
}

allProductsByNamespace(where: { namespace: $namespace }) {
name
id
environments {
id
name
}
}
allConsumerScopesAndRoles
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

query GetFilterConsumers($namespace: String!) {
allConsumerScopesAndRoles

allProductsByNamespace(where: { namespace: $namespace }) {
name
id
Expand All @@ -10,4 +8,5 @@
name
}
}
allConsumerScopesAndRoles
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

query GetServices($days: [String!]) {
allGatewayServicesByNamespace(first: 200) {
id
name
updatedAt
environment {
id
name
active
flow
product {
id
name
organization {
title
}
organizationUnit {
title
}
}
}
routes {
id
name
}
plugins {
id
name
}
}
allGatewayServiceMetricsByNamespace(
orderBy: "day_ASC"
where: { query: "kong_http_requests_hourly_namespace", day_in: $days }
) {
query
day
metric
values
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

query GetMetrics($service: String!, $days: [String!]) {
allGatewayServiceMetricsByNamespace(
orderBy: "day_ASC"
where: {
query: "kong_http_requests_hourly_service"
day_in: $days
service: { name_contains: $service }
}
) {
query
day
metric
values
service {
name
}
}
}
2 changes: 2 additions & 0 deletions src/authz/matrix.csv
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ Portal User,,regenerateCredentials,,,,,,,portal-user,,,allow,filterByAppOwner
Portal User,,myApplications,,,,,,,portal-user,,,allow,filterByOwner
API Owner Role Rules,,allGatewayServicesByNamespace,,,,,,,,,"api-owner,provider-user",allow,filterByUserNS
API Owner Role Rules,,allGatewayRoutesByNamespace,,,,,,,,,"api-owner,provider-user",allow,filterByUserNS
API Owner Role Rules,,allGatewayPluginsByNamespace,,,,,,,,,"api-owner,provider-user",allow,filterByUserNS
API Owner Role Rules,,allGatewayServiceMetricsByNamespace,,,,,,,,,"api-owner,provider-user",allow,filterByServiceNS
API Owner Role Rules,,allProductsByNamespace,,,,,,,,,"api-owner,provider-user",allow,filterByUserNS
API Owner Role Rules,,allNamespaceServiceAccounts,,,,,,,,,"api-owner,provider-user",allow,filterByUserNS
API Owner Role Rules,,allCredentialIssuersByNamespace,,,,,,,,,"api-owner,provider-user",allow,filterByUserNS
Expand Down
10 changes: 10 additions & 0 deletions src/lists/extensions/AliasedQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ module.exports = {
list: 'GatewayRoute',
type: SchemaType.ListQuery,
},
{
gqlName: 'allGatewayPluginsByNamespace',
list: 'GatewayPlugin',
type: SchemaType.ListQuery,
},
{
gqlName: 'allGatewayServiceMetricsByNamespace',
list: 'Metric',
type: SchemaType.ListQuery,
},
{
gqlName: 'allContentsByNamespace',
list: 'Content',
Expand Down
11 changes: 11 additions & 0 deletions src/mocks/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ import {
createServiceAccountHandler,
getAllServiceAccountsHandler,
} from './resolvers/service-accounts';
import {
allServicesHandler,
getMetricsHandler,
getGatewayServiceHandler,
getGatewayServiceFilterHandler,
} from './resolvers/services';

// Namespaces
const allNamespaces = [
Expand Down Expand Up @@ -125,8 +131,13 @@ export const handlers = [
keystone.query('MyApplications', allApplicationsHandler),
keystone.mutation('AddApplication', createApplicationHandler),
keystone.mutation('RemoveApplication', removeApplicationHandler),
// Services
keystone.query('GetServices', allServicesHandler),
keystone.query('GetMetrics', getMetricsHandler),
// Service accounts
keystone.query('GetAllServiceAccounts', getAllServiceAccountsHandler),
keystone.query('GetGatewayService', getGatewayServiceHandler),
keystone.query('GetGatewayServiceFilters', getGatewayServiceFilterHandler),
keystone.mutation('CreateServiceAccount', createServiceAccountHandler),
// Namespace Access
keystone.query('GetUserPermissions', getUserPermissionsHandler),
Expand Down
Loading