-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Security - remove auth scope provider #36998
Changes from 1 commit
3532524
f3bb7cc
962fdad
caa6fdd
35a5c7c
d5c1392
42f9c57
0b429ad
39d6757
909bcfe
d4a51cf
bf408a2
d6fc719
f79257a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,11 @@ | |
import Boom from 'boom'; | ||
|
||
import { | ||
AUTH_SCOPE_DASHBORD_ONLY_MODE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you please also get rid of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't believe I missed that! will do! |
||
CONFIG_DASHBOARD_ONLY_MODE_ROLES, | ||
} from '../common'; | ||
|
||
const superuserRole = 'superuser'; | ||
|
||
/** | ||
* Intercept all requests after auth has completed and apply filtering | ||
* logic to enforce `xpack:dashboardMode` scope | ||
|
@@ -27,7 +29,25 @@ export function createDashboardModeRequestInterceptor(dashboardViewerApp) { | |
const { auth, url } = request; | ||
const isAppRequest = url.path.startsWith('/app/'); | ||
|
||
if (isAppRequest && auth.credentials.scope && auth.credentials.scope.includes(AUTH_SCOPE_DASHBORD_ONLY_MODE)) { | ||
if (!isAppRequest) { | ||
return h.continue; | ||
} | ||
|
||
const user = auth.credentials; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic copied from |
||
|
||
const uiSettings = request.getUiSettingsService(); | ||
|
||
const dashboardOnlyModeRoles = await uiSettings.get(CONFIG_DASHBOARD_ONLY_MODE_ROLES); | ||
|
||
if (!dashboardOnlyModeRoles || user.roles.length === 0) { | ||
return; | ||
} | ||
|
||
const isDashboardOnlyModeUser = user.roles.find(role => dashboardOnlyModeRoles.includes(role)); | ||
const isSuperUser = user.roles.find(role => role === superuserRole); | ||
|
||
const enforceDashboardOnlyMode = isDashboardOnlyModeUser && !isSuperUser; | ||
if (enforceDashboardOnlyMode) { | ||
if (url.path.startsWith('/app/kibana')) { | ||
// If the user is in "Dashboard only mode" they should only be allowed to see | ||
// that app and none others. Here we are intercepting all other routing and ensuring the viewer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uh oh: we have a link to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ha, good catch, will remove |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: test title is outdated
not related: I've noticed we also reference to auth scope from comment in
x-pack/plugins/spaces/server/lib/request_inteceptors/on_post_auth_interceptor.ts
, probably some left over.