Skip to content

Commit

Permalink
Review#3: improve deprecation messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin committed Oct 18, 2021
1 parent e88267b commit 7fd0a88
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ describe('Kibana Dashboard Only User role deprecations', () => {
Object {
"correctiveActions": Object {
"manualSteps": Array [
"Create a custom role with Kibana privileges to restrict access to just the Dashboard feature.",
"Update all users to remove the \\"kibana_dashboard_only_user\\" role and add the custom role instead. The affected users are: userB, userD.",
"Create a custom role with Kibana privileges to grant access to Dashboard only.",
"Remove the \\"kibana_dashboard_only_user\\" role from all users and add the custom role. The affected users are: userB, userD.",
],
},
"deprecationType": "feature",
"documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/some-branch/built-in-roles.html",
"level": "warning",
"message": "Use a custom role with Kibana privileges to restrict access to just the Dashboard feature. The \\"kibana_dashboard_only_user\\" role will be removed in 8.0.",
"message": "Users with the \\"kibana_dashboard_only_user\\" role will not be able to access the Dashboard app. Use Kibana privileges instead.",
"title": "The \\"kibana_dashboard_only_user\\" role is deprecated",
},
]
Expand Down Expand Up @@ -248,14 +248,14 @@ describe('Kibana Dashboard Only User role deprecations', () => {
Object {
"correctiveActions": Object {
"manualSteps": Array [
"Create a custom role with Kibana privileges to restrict access to just the Dashboard feature.",
"Update all role mappings to remove the \\"kibana_dashboard_only_user\\" role and add the custom role instead. The affected role mappings are: mappingB, mappingD.",
"Create a custom role with Kibana privileges to grant access to Dashboard only.",
"Remove the \\"kibana_dashboard_only_user\\" role from all role mappings and add the custom role. The affected role mappings are: mappingB, mappingD.",
],
},
"deprecationType": "feature",
"documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/some-branch/built-in-roles.html",
"level": "warning",
"message": "Use a custom role with Kibana privileges to restrict access to just the Dashboard feature. The \\"kibana_dashboard_only_user\\" role will be removed in 8.0.",
"message": "Users with the \\"kibana_dashboard_only_user\\" role will not be able to access the Dashboard app. Use Kibana privileges instead.",
"title": "The \\"kibana_dashboard_only_user\\" role is deprecated",
},
]
Expand Down Expand Up @@ -293,27 +293,27 @@ describe('Kibana Dashboard Only User role deprecations', () => {
Object {
"correctiveActions": Object {
"manualSteps": Array [
"Create a custom role with Kibana privileges to restrict access to just the Dashboard feature.",
"Update all users to remove the \\"kibana_dashboard_only_user\\" role and add the custom role instead. The affected users are: userB, userD.",
"Create a custom role with Kibana privileges to grant access to Dashboard only.",
"Remove the \\"kibana_dashboard_only_user\\" role from all users and add the custom role. The affected users are: userB, userD.",
],
},
"deprecationType": "feature",
"documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/some-branch/built-in-roles.html",
"level": "warning",
"message": "Use a custom role with Kibana privileges to restrict access to just the Dashboard feature. The \\"kibana_dashboard_only_user\\" role will be removed in 8.0.",
"message": "Users with the \\"kibana_dashboard_only_user\\" role will not be able to access the Dashboard app. Use Kibana privileges instead.",
"title": "The \\"kibana_dashboard_only_user\\" role is deprecated",
},
Object {
"correctiveActions": Object {
"manualSteps": Array [
"Create a custom role with Kibana privileges to restrict access to just the Dashboard feature.",
"Update all role mappings to remove the \\"kibana_dashboard_only_user\\" role and add the custom role instead. The affected role mappings are: mappingB, mappingD.",
"Create a custom role with Kibana privileges to grant access to Dashboard only.",
"Remove the \\"kibana_dashboard_only_user\\" role from all role mappings and add the custom role. The affected role mappings are: mappingB, mappingD.",
],
},
"deprecationType": "feature",
"documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/some-branch/built-in-roles.html",
"level": "warning",
"message": "Use a custom role with Kibana privileges to restrict access to just the Dashboard feature. The \\"kibana_dashboard_only_user\\" role will be removed in 8.0.",
"message": "Users with the \\"kibana_dashboard_only_user\\" role will not be able to access the Dashboard app. Use Kibana privileges instead.",
"title": "The \\"kibana_dashboard_only_user\\" role is deprecated",
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ function getDeprecationTitle() {
});
}

function getDeprecationMessage() {
return i18n.translate('xpack.security.deprecations.kibanaDashboardOnlyUser.deprecationMessage', {
defaultMessage:
'Users with the "{roleName}" role will not be able to access the Dashboard app. Use Kibana privileges instead.',
values: { roleName: KIBANA_DASHBOARD_ONLY_USER_ROLE_NAME },
});
}

export const registerKibanaDashboardOnlyRoleDeprecation = ({
deprecationsService,
logger,
Expand Down Expand Up @@ -92,14 +100,7 @@ async function getUsersDeprecations(
return [
{
title: getDeprecationTitle(),
message: i18n.translate(
'xpack.security.deprecations.kibanaDashboardOnlyUser.usersDeprecationMessage',
{
defaultMessage:
'Use a custom role with Kibana privileges to restrict access to just the Dashboard feature. The "{roleName}" role will be removed in 8.0.',
values: { roleName: KIBANA_DASHBOARD_ONLY_USER_ROLE_NAME },
}
),
message: getDeprecationMessage(),
level: 'warning',
deprecationType: 'feature',
documentationUrl: `https://www.elastic.co/guide/en/elasticsearch/reference/${packageInfo.branch}/built-in-roles.html`,
Expand All @@ -109,14 +110,14 @@ async function getUsersDeprecations(
'xpack.security.deprecations.kibanaDashboardOnlyUser.usersDeprecationCorrectiveActionOne',
{
defaultMessage:
'Create a custom role with Kibana privileges to restrict access to just the Dashboard feature.',
'Create a custom role with Kibana privileges to grant access to Dashboard only.',
}
),
i18n.translate(
'xpack.security.deprecations.kibanaDashboardOnlyUser.usersDeprecationCorrectiveActionTwo',
{
defaultMessage:
'Update all users to remove the "{roleName}" role and add the custom role instead. The affected users are: {users}.',
'Remove the "{roleName}" role from all users and add the custom role. The affected users are: {users}.',
values: {
roleName: KIBANA_DASHBOARD_ONLY_USER_ROLE_NAME,
users: usersWithKibanaDashboardOnlyRole.join(', '),
Expand Down Expand Up @@ -162,14 +163,7 @@ async function getRoleMappingsDeprecations(
return [
{
title: getDeprecationTitle(),
message: i18n.translate(
'xpack.security.deprecations.kibanaDashboardOnlyUser.roleMappingsDeprecationMessage',
{
defaultMessage:
'Use a custom role with Kibana privileges to restrict access to just the Dashboard feature. The "{roleName}" role will be removed in 8.0.',
values: { roleName: KIBANA_DASHBOARD_ONLY_USER_ROLE_NAME },
}
),
message: getDeprecationMessage(),
level: 'warning',
deprecationType: 'feature',
documentationUrl: `https://www.elastic.co/guide/en/elasticsearch/reference/${packageInfo.branch}/built-in-roles.html`,
Expand All @@ -179,14 +173,14 @@ async function getRoleMappingsDeprecations(
'xpack.security.deprecations.kibanaDashboardOnlyUser.roleMappingsDeprecationCorrectiveActionOne',
{
defaultMessage:
'Create a custom role with Kibana privileges to restrict access to just the Dashboard feature.',
'Create a custom role with Kibana privileges to grant access to Dashboard only.',
}
),
i18n.translate(
'xpack.security.deprecations.kibanaDashboardOnlyUser.roleMappingsDeprecationCorrectiveActionTwo',
{
defaultMessage:
'Update all role mappings to remove the "{roleName}" role and add the custom role instead. The affected role mappings are: {roleMappings}.',
'Remove the "{roleName}" role from all role mappings and add the custom role. The affected role mappings are: {roleMappings}.',
values: {
roleName: KIBANA_DASHBOARD_ONLY_USER_ROLE_NAME,
roleMappings: roleMappingsWithKibanaDashboardOnlyRole.join(', '),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ describe('Kibana Dashboard Only User role deprecations', () => {
"path": "/internal/security/deprecations/kibana_user_role/_fix_users",
},
"manualSteps": Array [
"Update all users to remove the \\"kibana_user\\" role and add the \\"kibana_admin\\" role instead. The affected users are: userB, userD.",
"Remove the \\"kibana_user\\" role from all users and add the \\"kibana_admin\\" role. The affected users are: userB, userD.",
],
},
"deprecationType": "feature",
"documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/some-branch/built-in-roles.html",
"level": "warning",
"message": "Use the \\"kibana_admin\\" role to grant access to all Kibana features in all spaces. The \\"kibana_user\\" role will be removed in a future release.",
"message": "Use the \\"kibana_admin\\" role to grant access to all Kibana features in all spaces.",
"title": "The \\"kibana_user\\" role is deprecated",
},
]
Expand Down Expand Up @@ -252,13 +252,13 @@ describe('Kibana Dashboard Only User role deprecations', () => {
"path": "/internal/security/deprecations/kibana_user_role/_fix_role_mappings",
},
"manualSteps": Array [
"Update all role mappings to remove the \\"kibana_user\\" role and add the \\"kibana_admin\\" role instead. The affected role mappings are: mappingB, mappingD.",
"Remove the \\"kibana_user\\" role from all role mappings and add the \\"kibana_admin\\" role. The affected role mappings are: mappingB, mappingD.",
],
},
"deprecationType": "feature",
"documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/some-branch/built-in-roles.html",
"level": "warning",
"message": "Use the \\"kibana_admin\\" role to grant access to all Kibana features in all spaces. The \\"kibana_user\\" role will be removed in a future release.",
"message": "Use the \\"kibana_admin\\" role to grant access to all Kibana features in all spaces.",
"title": "The \\"kibana_user\\" role is deprecated",
},
]
Expand Down Expand Up @@ -297,13 +297,13 @@ describe('Kibana Dashboard Only User role deprecations', () => {
"path": "/internal/security/deprecations/kibana_user_role/_fix_users",
},
"manualSteps": Array [
"Update all users to remove the \\"kibana_user\\" role and add the \\"kibana_admin\\" role instead. The affected users are: userB, userD.",
"Remove the \\"kibana_user\\" role from all users and add the \\"kibana_admin\\" role. The affected users are: userB, userD.",
],
},
"deprecationType": "feature",
"documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/some-branch/built-in-roles.html",
"level": "warning",
"message": "Use the \\"kibana_admin\\" role to grant access to all Kibana features in all spaces. The \\"kibana_user\\" role will be removed in a future release.",
"message": "Use the \\"kibana_admin\\" role to grant access to all Kibana features in all spaces.",
"title": "The \\"kibana_user\\" role is deprecated",
},
Object {
Expand All @@ -313,13 +313,13 @@ describe('Kibana Dashboard Only User role deprecations', () => {
"path": "/internal/security/deprecations/kibana_user_role/_fix_role_mappings",
},
"manualSteps": Array [
"Update all role mappings to remove the \\"kibana_user\\" role and add the \\"kibana_admin\\" role instead. The affected role mappings are: mappingB, mappingD.",
"Remove the \\"kibana_user\\" role from all role mappings and add the \\"kibana_admin\\" role. The affected role mappings are: mappingB, mappingD.",
],
},
"deprecationType": "feature",
"documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/some-branch/built-in-roles.html",
"level": "warning",
"message": "Use the \\"kibana_admin\\" role to grant access to all Kibana features in all spaces. The \\"kibana_user\\" role will be removed in a future release.",
"message": "Use the \\"kibana_admin\\" role to grant access to all Kibana features in all spaces.",
"title": "The \\"kibana_user\\" role is deprecated",
},
]
Expand Down
27 changes: 12 additions & 15 deletions x-pack/plugins/security/server/deprecations/kibana_user_role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ function getDeprecationTitle() {
});
}

function getDeprecationMessage() {
return i18n.translate('xpack.security.deprecations.kibanaUser.deprecationMessage', {
defaultMessage:
'Use the "{adminRoleName}" role to grant access to all Kibana features in all spaces.',
values: { adminRoleName: KIBANA_ADMIN_ROLE_NAME },
});
}

export const registerKibanaUserRoleDeprecation = ({
deprecationsService,
logger,
Expand Down Expand Up @@ -93,11 +101,7 @@ async function getUsersDeprecations(
return [
{
title: getDeprecationTitle(),
message: i18n.translate('xpack.security.deprecations.kibanaUser.usersDeprecationMessage', {
defaultMessage:
'Use the "{adminRoleName}" role to grant access to all Kibana features in all spaces. The "{userRoleName}" role will be removed in a future release.',
values: { userRoleName: KIBANA_USER_ROLE_NAME, adminRoleName: KIBANA_ADMIN_ROLE_NAME },
}),
message: getDeprecationMessage(),
level: 'warning',
deprecationType: 'feature',
documentationUrl: `https://www.elastic.co/guide/en/elasticsearch/reference/${packageInfo.branch}/built-in-roles.html`,
Expand All @@ -111,7 +115,7 @@ async function getUsersDeprecations(
'xpack.security.deprecations.kibanaUser.usersDeprecationCorrectiveAction',
{
defaultMessage:
'Update all users to remove the "{userRoleName}" role and add the "{adminRoleName}" role instead. The affected users are: {users}.',
'Remove the "{userRoleName}" role from all users and add the "{adminRoleName}" role. The affected users are: {users}.',
values: {
userRoleName: KIBANA_USER_ROLE_NAME,
adminRoleName: KIBANA_ADMIN_ROLE_NAME,
Expand Down Expand Up @@ -158,14 +162,7 @@ async function getRoleMappingsDeprecations(
return [
{
title: getDeprecationTitle(),
message: i18n.translate(
'xpack.security.deprecations.kibanaUser.roleMappingsDeprecationMessage',
{
defaultMessage:
'Use the "{adminRoleName}" role to grant access to all Kibana features in all spaces. The "{userRoleName}" role will be removed in a future release.',
values: { userRoleName: KIBANA_USER_ROLE_NAME, adminRoleName: KIBANA_ADMIN_ROLE_NAME },
}
),
message: getDeprecationMessage(),
level: 'warning',
deprecationType: 'feature',
documentationUrl: `https://www.elastic.co/guide/en/elasticsearch/reference/${packageInfo.branch}/built-in-roles.html`,
Expand All @@ -179,7 +176,7 @@ async function getRoleMappingsDeprecations(
'xpack.security.deprecations.kibanaUser.roleMappingsDeprecationCorrectiveAction',
{
defaultMessage:
'Update all role mappings to remove the "{userRoleName}" role and add the "{adminRoleName}" role instead. The affected role mappings are: {roleMappings}.',
'Remove the "{userRoleName}" role from all role mappings and add the "{adminRoleName}" role. The affected role mappings are: {roleMappings}.',
values: {
userRoleName: KIBANA_USER_ROLE_NAME,
adminRoleName: KIBANA_ADMIN_ROLE_NAME,
Expand Down

0 comments on commit 7fd0a88

Please sign in to comment.