Skip to content

Commit

Permalink
[FIX JENKINS-40755] Disable settings link when user does not have edi…
Browse files Browse the repository at this point in the history
…t permissions (#825)

* CONFIGURE_PERMISSION pipeline permission

* CONFIGURE_PERMISSION pipeline permission in JS Security module

* core-js 0.0.68-tf-JENKINS-40755-2

* core-js 0.0.68-tf-JENKINS-40755-2 on dependants

* fix lint errors

* core-js 0.0.68

* core-js 0.0.68 on dependants
  • Loading branch information
tfennelly authored Feb 15, 2017
1 parent f0e46cd commit 32b9f38
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion blueocean-core-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jenkins-cd/blueocean-core-js",
"version": "0.0.67",
"version": "0.0.68",
"description": "Shared JavaScript libraries for use with Jenkins Blue Ocean",
"main": "dist/js/index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions blueocean-core-js/src/js/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const permit = (subject) => {

return {
read: () => checkPermissions('read'),
configure: () => checkPermissions('configure'),
create: () => checkPermissions('create'),
start: () => checkPermissions('start'),
stop: () => checkPermissions('stop'),
Expand Down
20 changes: 10 additions & 10 deletions blueocean-dashboard/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blueocean-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"skin-deep": "0.16.0"
},
"dependencies": {
"@jenkins-cd/blueocean-core-js": "0.0.67",
"@jenkins-cd/blueocean-core-js": "0.0.68",
"@jenkins-cd/design-language": "0.0.112",
"@jenkins-cd/js-extensions": "0.0.33",
"@jenkins-cd/js-modules": "0.0.8",
Expand Down
4 changes: 2 additions & 2 deletions blueocean-dashboard/src/main/js/components/PipelinePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
TabLink,
WeatherIcon,
} from '@jenkins-cd/design-language';
import { i18nTranslator, NotFound, User, Paths, ContentPageHeader, logging, AppConfig } from '@jenkins-cd/blueocean-core-js';
import { i18nTranslator, NotFound, Paths, ContentPageHeader, logging, AppConfig, Security } from '@jenkins-cd/blueocean-core-js';
import { Icon } from '@jenkins-cd/react-material-icons';
import PageLoading from './PageLoading';
import { buildOrganizationUrl, buildPipelineUrl, buildClassicConfigUrl } from '../util/UrlUtils';
Expand All @@ -21,7 +21,7 @@ const RestPaths = Paths.rest;

const classicConfigLink = (pipeline) => {
let link = null;
if (!User.current().isAnonymous()) {
if (Security.permit(pipeline).configure()) {
link = <a href={buildClassicConfigUrl(pipeline)} target="_blank"><Icon size={24} icon="settings" style={{ fill: '#fff' }} /></a>;
}
return link;
Expand Down
5 changes: 2 additions & 3 deletions blueocean-dashboard/src/main/js/components/RunDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import { RunDetailsHeader } from './RunDetailsHeader';
import { RunRecord } from './records';
import { FullScreen } from './FullScreen';
import PageLoading from './PageLoading';
import { Paths, capable, locationService } from '@jenkins-cd/blueocean-core-js';
import { Paths, capable, locationService, Security } from '@jenkins-cd/blueocean-core-js';
import { observer } from 'mobx-react';
import { User } from '@jenkins-cd/blueocean-core-js';

const { func, object, any, string } = PropTypes;

Expand All @@ -26,7 +25,7 @@ const logger = logging.logger('io.jenkins.blueocean.dashboard.RunDetails');

const classicConfigLink = (pipeline) => {
let link = null;
if (!User.current().isAnonymous()) {
if (Security.permit(pipeline).configure()) {
let url = buildClassicConfigUrl(pipeline);
link = (
<a href={ url } target="_blank" style={ { height: '24px' } }>
Expand Down
6 changes: 3 additions & 3 deletions blueocean-personalization/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blueocean-personalization/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"react-addons-test-utils": "15.3.2"
},
"dependencies": {
"@jenkins-cd/blueocean-core-js": "0.0.67",
"@jenkins-cd/blueocean-core-js": "0.0.68",
"@jenkins-cd/design-language": "0.0.112",
"@jenkins-cd/js-extensions": "0.0.33",
"@jenkins-cd/js-modules": "0.0.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public Map<String, Boolean> getPermissions(){
public static Map<String, Boolean> getPermissions(AbstractItem item){
return ImmutableMap.of(
BluePipeline.CREATE_PERMISSION, item.getACL().hasPermission(Item.CREATE),
BluePipeline.CONFIGURE_PERMISSION, item.getACL().hasPermission(Item.CONFIGURE),
BluePipeline.READ_PERMISSION, item.getACL().hasPermission(Item.READ),
BluePipeline.START_PERMISSION, item.getACL().hasPermission(Item.BUILD),
BluePipeline.STOP_PERMISSION, item.getACL().hasPermission(Item.CANCEL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public abstract class BluePipeline extends Resource {
/** Create pipeline */
public static final String CREATE_PERMISSION = "create";

/** Configure pipeline */
public static final String CONFIGURE_PERMISSION = "configure";

/** Read pipeline permission */
public static final String READ_PERMISSION = "read";

Expand Down
6 changes: 3 additions & 3 deletions blueocean-web/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blueocean-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"zombie": "4.2.1"
},
"dependencies": {
"@jenkins-cd/blueocean-core-js": "0.0.67",
"@jenkins-cd/blueocean-core-js": "0.0.68",
"@jenkins-cd/design-language": "0.0.112",
"@jenkins-cd/js-extensions": "0.0.33",
"@jenkins-cd/js-modules": "0.0.8",
Expand Down

0 comments on commit 32b9f38

Please sign in to comment.