diff --git a/blueocean-core-js/package.json b/blueocean-core-js/package.json index 87313174578..7f6d1418941 100644 --- a/blueocean-core-js/package.json +++ b/blueocean-core-js/package.json @@ -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": { diff --git a/blueocean-core-js/src/js/security.js b/blueocean-core-js/src/js/security.js index d78ad84755c..ac3d56d5eea 100644 --- a/blueocean-core-js/src/js/security.js +++ b/blueocean-core-js/src/js/security.js @@ -20,6 +20,7 @@ const permit = (subject) => { return { read: () => checkPermissions('read'), + configure: () => checkPermissions('configure'), create: () => checkPermissions('create'), start: () => checkPermissions('start'), stop: () => checkPermissions('stop'), diff --git a/blueocean-dashboard/npm-shrinkwrap.json b/blueocean-dashboard/npm-shrinkwrap.json index f92fb9d7248..287d6232f76 100644 --- a/blueocean-dashboard/npm-shrinkwrap.json +++ b/blueocean-dashboard/npm-shrinkwrap.json @@ -3,9 +3,9 @@ "version": "0.0.1", "dependencies": { "@jenkins-cd/blueocean-core-js": { - "version": "0.0.67", - "from": "@jenkins-cd/blueocean-core-js@0.0.67", - "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.67.tgz" + "version": "0.0.68", + "from": "@jenkins-cd/blueocean-core-js@0.0.68", + "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.68.tgz" }, "@jenkins-cd/design-language": { "version": "0.0.112", @@ -4324,7 +4324,7 @@ }, "inherits": { "version": "2.0.3", - "from": "inherits@>=2.0.0 <3.0.0", + "from": "inherits@>=2.0.1 <2.1.0", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz" }, "ini": { @@ -4698,7 +4698,7 @@ }, "js-yaml": { "version": "3.7.0", - "from": "js-yaml@>=3.6.0 <4.0.0", + "from": "js-yaml@>=3.5.1 <4.0.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.7.0.tgz" }, "jsbn": { @@ -5616,7 +5616,7 @@ }, "minimatch": { "version": "3.0.3", - "from": "minimatch@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", + "from": "minimatch@>=3.0.2 <4.0.0", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz" }, "minimist": { @@ -5702,7 +5702,7 @@ }, "ms": { "version": "0.7.2", - "from": "ms@>=0.7.1 <0.8.0", + "from": "ms@0.7.2", "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" }, "multimatch": { @@ -5954,7 +5954,7 @@ }, "object-assign": { "version": "4.1.0", - "from": "object-assign@>=4.1.0 <5.0.0", + "from": "object-assign@>=4.0.1 <5.0.0", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz" }, "object-inspect": { @@ -7658,7 +7658,7 @@ }, "through": { "version": "2.3.8", - "from": "through@>=2.3.4 <2.4.0", + "from": "through@>=2.3.6 <3.0.0", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" }, "through2": { @@ -8340,7 +8340,7 @@ }, "xtend": { "version": "4.0.1", - "from": "xtend@>=4.0.1 <5.0.0", + "from": "xtend@>=4.0.0 <5.0.0", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" }, "yargs": { diff --git a/blueocean-dashboard/package.json b/blueocean-dashboard/package.json index 4e8d4574c70..da878542f43 100644 --- a/blueocean-dashboard/package.json +++ b/blueocean-dashboard/package.json @@ -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", diff --git a/blueocean-dashboard/src/main/js/components/PipelinePage.jsx b/blueocean-dashboard/src/main/js/components/PipelinePage.jsx index e49be4327e5..8844836b9c9 100644 --- a/blueocean-dashboard/src/main/js/components/PipelinePage.jsx +++ b/blueocean-dashboard/src/main/js/components/PipelinePage.jsx @@ -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'; @@ -21,7 +21,7 @@ const RestPaths = Paths.rest; const classicConfigLink = (pipeline) => { let link = null; - if (!User.current().isAnonymous()) { + if (Security.permit(pipeline).configure()) { link = ; } return link; diff --git a/blueocean-dashboard/src/main/js/components/RunDetails.jsx b/blueocean-dashboard/src/main/js/components/RunDetails.jsx index d7def7f4347..887a71850aa 100644 --- a/blueocean-dashboard/src/main/js/components/RunDetails.jsx +++ b/blueocean-dashboard/src/main/js/components/RunDetails.jsx @@ -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; @@ -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 = ( diff --git a/blueocean-personalization/npm-shrinkwrap.json b/blueocean-personalization/npm-shrinkwrap.json index 0843b4c1000..b2086bd818a 100644 --- a/blueocean-personalization/npm-shrinkwrap.json +++ b/blueocean-personalization/npm-shrinkwrap.json @@ -3,9 +3,9 @@ "version": "0.0.2-unpublished", "dependencies": { "@jenkins-cd/blueocean-core-js": { - "version": "0.0.67", - "from": "@jenkins-cd/blueocean-core-js@0.0.67", - "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.67.tgz" + "version": "0.0.68", + "from": "@jenkins-cd/blueocean-core-js@0.0.68", + "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.68.tgz" }, "@jenkins-cd/design-language": { "version": "0.0.112", diff --git a/blueocean-personalization/package.json b/blueocean-personalization/package.json index 3b71a84c8e7..4867a8a04ab 100644 --- a/blueocean-personalization/package.json +++ b/blueocean-personalization/package.json @@ -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", diff --git a/blueocean-rest-impl/src/main/java/io/jenkins/blueocean/service/embedded/rest/AbstractPipelineImpl.java b/blueocean-rest-impl/src/main/java/io/jenkins/blueocean/service/embedded/rest/AbstractPipelineImpl.java index 8d18d409ba9..45c0f62f839 100644 --- a/blueocean-rest-impl/src/main/java/io/jenkins/blueocean/service/embedded/rest/AbstractPipelineImpl.java +++ b/blueocean-rest-impl/src/main/java/io/jenkins/blueocean/service/embedded/rest/AbstractPipelineImpl.java @@ -304,6 +304,7 @@ public Map getPermissions(){ public static Map 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) diff --git a/blueocean-rest/src/main/java/io/jenkins/blueocean/rest/model/BluePipeline.java b/blueocean-rest/src/main/java/io/jenkins/blueocean/rest/model/BluePipeline.java index 27aac834678..027531e24df 100644 --- a/blueocean-rest/src/main/java/io/jenkins/blueocean/rest/model/BluePipeline.java +++ b/blueocean-rest/src/main/java/io/jenkins/blueocean/rest/model/BluePipeline.java @@ -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"; diff --git a/blueocean-web/npm-shrinkwrap.json b/blueocean-web/npm-shrinkwrap.json index a6c0bc21aac..8c7a216c6e8 100644 --- a/blueocean-web/npm-shrinkwrap.json +++ b/blueocean-web/npm-shrinkwrap.json @@ -3,9 +3,9 @@ "version": "0.0.1", "dependencies": { "@jenkins-cd/blueocean-core-js": { - "version": "0.0.67", - "from": "@jenkins-cd/blueocean-core-js@0.0.67", - "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.67.tgz" + "version": "0.0.68", + "from": "@jenkins-cd/blueocean-core-js@0.0.68", + "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.68.tgz" }, "@jenkins-cd/design-language": { "version": "0.0.112", diff --git a/blueocean-web/package.json b/blueocean-web/package.json index dc3c367e307..8cc9fcb75b4 100644 --- a/blueocean-web/package.json +++ b/blueocean-web/package.json @@ -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",