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

[hotfix] Fixed DNS Provider List not visible for non-admin users #1337

Merged
merged 1 commit into from
Nov 4, 2022
Merged
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
12 changes: 10 additions & 2 deletions backend/__fixtures__/controllerregistrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const controllerRegistrationList = [
}]
}),
getControllerRegistration({
uid: 2,
uid: 3,
name: 'Network Registration 2',
resources: [{
kind: 'Network',
Expand All @@ -62,13 +62,21 @@ const controllerRegistrationList = [
}]
}),
getControllerRegistration({
uid: 2,
uid: 4,
name: 'Provider-Foo',
resources: [{
kind: 'DNSRecord',
type: 'gardenland',
primary: true
}]
}),
getControllerRegistration({
uid: 5,
name: 'extension-shoot-dns-service',
resources: [{
kind: 'Foo',
type: 'bar'
}]
})
]

Expand Down
5 changes: 3 additions & 2 deletions backend/lib/services/controllerregistrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const { getControllerRegistrations } = require('../cache')
const authorization = require('./authorization')
const _ = require('lodash')

const REQUIRED_RESOURCE_KINDS = ['Network', 'DNSProvider']
const REQUIRED_RESOURCE_KINDS = ['Network', 'DNSRecord']
const REQUIRED_RESOURCE_NAMES = ['extension-shoot-dns-service']
exports.listExtensions = async function ({ user }) {
const controllerregistrations = getControllerRegistrations()
const allowed = await authorization.canListControllerRegistrations(user)
Expand All @@ -25,7 +26,7 @@ exports.listExtensions = async function ({ user }) {
// required resoure kinds are essential for the frontend and need to be returned even if the user has not the permission to read controllerregistrations
const resources = _.filter(spec.resources, ({ kind }) => REQUIRED_RESOURCE_KINDS.includes(kind))
// only expose the extension if it contains one of the required resources
if (!_.isEmpty(resources)) {
if (!_.isEmpty(resources) || REQUIRED_RESOURCE_NAMES.includes(name)) {
extensions.push({ name, resources })
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ Array [
},
],
},
Object {
"name": "extension-shoot-dns-service",
"resources": Array [
Object {
"kind": "Foo",
"type": "bar",
},
],
},
]
`;

Expand Down Expand Up @@ -119,5 +128,19 @@ Array [
},
],
},
Object {
"name": "Provider-Foo",
"resources": Array [
Object {
"kind": "DNSRecord",
"primary": true,
"type": "gardenland",
},
],
},
Object {
"name": "extension-shoot-dns-service",
"resources": Array [],
},
]
`;