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

Remove internal version endpoint #25998

Merged
merged 5 commits into from
Mar 21, 2024
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
3 changes: 0 additions & 3 deletions changelog/23740.txt

This file was deleted.

9 changes: 2 additions & 7 deletions ui/app/adapters/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const ENDPOINTS = [
'init',
'capabilities-self',
'license',
'internal/ui/version',
];

const REPLICATION_ENDPOINTS = {
Expand Down Expand Up @@ -100,12 +99,8 @@ export default ApplicationAdapter.extend({
});
},

fetchVersion() {
return this.ajax(`${this.urlFor('internal/ui/version')}`, 'GET').catch(() => ({}));
},

sealStatus() {
return this.ajax(this.urlFor('seal-status'), 'GET', { unauthenticated: true });
sealStatus(unauthenticated = true) {
return this.ajax(this.urlFor('seal-status'), 'GET', { unauthenticated });
},

seal() {
Expand Down
5 changes: 3 additions & 2 deletions ui/app/services/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ export default class VersionService extends Service {
@task({ drop: true })
*getVersion() {
if (this.version) return;
const response = yield this.store.adapterFor('cluster').fetchVersion();
this.version = response.data?.version;
// Fetch seal status with token to get version
const response = yield this.store.adapterFor('cluster').sealStatus(false);
this.version = response?.version;
}

@task
Expand Down
8 changes: 0 additions & 8 deletions ui/mirage/handlers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ export default function (server) {
};
});

server.get('/sys/internal/ui/version', function () {
return {
data: {
version: '1.9.0+ent',
},
};
});

server.get('/sys/license/status', function () {
return {
data: {
Expand Down
10 changes: 7 additions & 3 deletions ui/mirage/handlers/reduced-disclosure.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ export default function (server) {
server.get('/sys/health', (schema, req) =>
modifyPassthroughResponse(req, { version: '', cluster_name: '' })
);
server.get('/sys/seal-status', (schema, req) =>
modifyPassthroughResponse(req, { version: '', cluster_name: '', build_date: '' })
);
server.get('/sys/seal-status', (schema, req) => {
// When reduced disclosure is active, the version is only returned when a valid token is used
const overrides = req.requestHeaders['X-Vault-Token']
? { cluster_name: '', build_date: '' }
: { version: '', cluster_name: '', build_date: '' };
return modifyPassthroughResponse(req, overrides);
});
server.get('sys/replication/status', () => new Response(404, {}, { errors: ['disabled path'] }));
server.get('sys/replication/dr/status', () => new Response(404, {}, { errors: ['disabled path'] }));
server.get(
Expand Down
15 changes: 0 additions & 15 deletions ui/tests/acceptance/config-ui/messages/messages-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ module('Acceptance | Community | config-ui/messages', function (hooks) {
setupMirage(hooks);

hooks.beforeEach(async function () {
this.server.get('sys/internal/ui/version', function () {
return {
data: {
version: '1.16.0',
},
};
});

this.server.get('/sys/health', function () {
return {
enterprise: false,
Expand Down Expand Up @@ -100,13 +92,6 @@ module('Acceptance | Enterprise | config-ui/message', function (hooks) {

await click(PAGE.button('create-message'));
};
this.server.get('sys/internal/ui/version', function () {
return {
data: {
version: '1.16.0+ent',
},
};
});
this.server.get('/sys/health', function () {
return {
enterprise: true,
Expand Down
4 changes: 3 additions & 1 deletion ui/tests/acceptance/dashboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ module('Acceptance | landing page dashboard', function (hooks) {
await visit('/vault/dashboard');
const version = this.owner.lookup('service:version');
// Since we're using mirage, version is mocked static value
const versionText = version.isEnterprise ? `Vault v1.9.0 root` : `Vault v1.9.0`;
const versionText = version.isEnterprise
? `Vault ${version.versionDisplay} root`
: `Vault ${version.versionDisplay}`;

assert.dom(SELECTORS.cardHeader('Vault version')).hasText(versionText);
});
Expand Down
11 changes: 4 additions & 7 deletions ui/tests/acceptance/reduced-disclosure-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module('Acceptance | reduced disclosure test', function (hooks) {
type: 'shamir',
initialized: true,
sealed: this.sealed,
version: '1.21.3',
};
});
this.server.put(`/sys/seal`, () => {
Expand All @@ -84,11 +85,9 @@ module('Acceptance | reduced disclosure test', function (hooks) {
});
await authPage.login();

const versionSvc = this.owner.lookup('service:version');
await visit('/vault/settings/seal');
assert
.dom('[data-test-footer-version]')
.hasText(`Vault ${versionSvc.version}`, 'shows version on seal page');

assert.dom('[data-test-footer-version]').hasText(`Vault 1.21.3`, 'shows version on seal page');
assert.strictEqual(currentURL(), '/vault/settings/seal');

// seal
Expand All @@ -115,9 +114,7 @@ module('Acceptance | reduced disclosure test', function (hooks) {
assert.strictEqual(currentRouteName(), 'vault.cluster.auth', 'vault is ready to authenticate');
assert.dom('[data-test-footer-version]').hasText(`Vault`, 'Version is still not shown before auth');
await authPage.login();
assert
.dom('[data-test-footer-version]')
.hasText(`Vault ${versionSvc.version}`, 'Version is shown after login');
assert.dom('[data-test-footer-version]').hasText(`Vault 1.21.3`, 'Version is shown after login');
});

module('enterprise', function () {
Expand Down
10 changes: 10 additions & 0 deletions ui/tests/unit/services/version-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ module('Unit | Service | version', function (hooks) {
assert.true(service.isEnterprise);
});

test('calculates versionDisplay correctly', function (assert) {
const service = this.owner.lookup('service:version');
service.type = 'community';
service.version = '1.2.3';
assert.strictEqual(service.versionDisplay, 'v1.2.3');
service.type = 'enterprise';
service.version = '1.4.7+ent';
assert.strictEqual(service.versionDisplay, 'v1.4.7');
});

test('hasPerfReplication', function (assert) {
const service = this.owner.lookup('service:version');
assert.false(service.hasPerfReplication);
Expand Down
12 changes: 0 additions & 12 deletions vault/logical_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -5249,18 +5249,6 @@ func (b *SystemBackend) pathInternalUIResultantACL(ctx context.Context, req *log
return resp, nil
}

// pathInternalUIVersion is the framework.PathOperation callback function for
// the sys/internal/ui/version path. It simply returns the Vault version.
func (b *SystemBackend) pathInternalUIVersion(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
resp := &logical.Response{
Data: map[string]any{
"version": version.GetVersion().VersionNumber(),
},
}

return resp, nil
}

func (b *SystemBackend) pathInternalOpenAPI(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
// Limit output to authorized paths
resp, err := b.pathInternalUIMountsRead(ctx, req, d)
Expand Down
5 changes: 0 additions & 5 deletions vault/logical_system_integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ func TestSystemBackend_InternalUIResultantACL(t *testing.T) {
"read",
},
},
"sys/internal/ui/version": map[string]interface{}{
"capabilities": []interface{}{
"read",
},
},
"sys/leases/lookup": map[string]interface{}{
"capabilities": []interface{}{
"update",
Expand Down
25 changes: 0 additions & 25 deletions vault/logical_system_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -2895,31 +2895,6 @@ func (b *SystemBackend) internalPaths() []*framework.Path {
},
},
},
{
Pattern: "internal/ui/version",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "internal-ui",
OperationVerb: "read",
OperationSuffix: "version",
},
Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathInternalUIVersion,
Summary: "Backwards compatibility is not guaranteed for this API",
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"version": {
Type: framework.TypeString,
Required: true,
},
},
}},
},
},
},
},
{
Pattern: "internal/counters/requests",
DisplayAttrs: &framework.DisplayAttributes{
Expand Down
6 changes: 0 additions & 6 deletions vault/policy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ path "sys/internal/ui/resultant-acl" {
capabilities = ["read"]
}

# Allow a token to look up the Vault version. This path is not subject to
# redaction like the unauthenticated endpoints that provide the Vault version.
path "sys/internal/ui/version" {
capabilities = ["read"]
}

# Allow a token to renew a lease via lease_id in the request body; old path for
# old clients, new path for newer
path "sys/renew" {
Expand Down
51 changes: 0 additions & 51 deletions website/content/api-docs/system/internal-ui-version.mdx

This file was deleted.

4 changes: 0 additions & 4 deletions website/data/api-docs-nav-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,6 @@
"title": "<code>/sys/internal/ui/unauthenticated-messages</code>",
"path": "system/internal-ui-unauthenticated-messages"
},
{
"title": "<code>/sys/internal/ui/version</code>",
"path": "system/internal-ui-version"
},
{
"title": "<code>/sys/key-status</code>",
"path": "system/key-status"
Expand Down
Loading