diff --git a/CHANGELOG.md b/CHANGELOG.md index daee9aa86b..97dff642cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Changed +- Simplified collapse state management of the secondary navigation ([#1086](https://github.com/scm-manager/scm-manager/pull/1086) + +### Fixed +- Authentication for write requests for repositories with anonymous read access ([#108](https://github.com/scm-manager/scm-manager/pull/1081)) + + +## 2.0.0-rc6 - 2020-03-26 ### Added - Extension point to add links to the repository cards from plug ins ([#1041](https://github.com/scm-manager/scm-manager/pull/1041)) - Libc based restart strategy for posix operating systems ([#1079](https://github.com/scm-manager/scm-manager/pull/1079)) - Simple restart strategy with System.exit ([#1079](https://github.com/scm-manager/scm-manager/pull/1079)) - Notification if restart is not supported on the underlying platform ([#1079](https://github.com/scm-manager/scm-manager/pull/1079)) +- Extension point before title in repository cards ([#1080](https://github.com/scm-manager/scm-manager/pull/1080)) +- Extension point after title on repository detail page ([#1080](https://github.com/scm-manager/scm-manager/pull/1080)) ### Changed - Update resteasy to version 4.5.2.Final diff --git a/Jenkinsfile b/Jenkinsfile index 39173ab389..a6ca00bb51 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,7 +48,7 @@ node('docker') { sh "git -c user.name='CES Marvin' -c user.email='cesmarvin@cloudogu.com' commit -m 'release version ${releaseVersion}'" // we need to fetch all branches, so we can checkout master and develop later - sh "git config 'remote.origin.fetch +refs/heads/*:refs/remotes/origin/*'" + sh "git config 'remote.origin.fetch' '+refs/heads/*:refs/remotes/origin/*'" sh "git fetch --all" // merge release branch into master diff --git a/docs/v2/release-process.md b/docs/v2/release-process.md index 3ebf091572..83f4db8ce2 100644 --- a/docs/v2/release-process.md +++ b/docs/v2/release-process.md @@ -7,7 +7,7 @@ To release a new version of SCM-Manager v2 you have to do the following steps (r Make sure you have no changes you want to keep! ``` -git fetch && git checkout default && git reset --hard origin/default +git fetch && git checkout develop && git reset --hard origin/develop ``` ## Modify Changelog @@ -114,3 +114,7 @@ Edit `package.json`: `version` has to be set to the new development version. git commit -am "Prepare for next development iteration" git push origin develop ``` +## Attention: Creating new plugins +If you are creating a new plugin which doesn't exist in the SCM-Manager Plugin-Center yet, your plugin will not be shown after the release. First you have to create a `index.md` in the Plugin-Center Repository. + +Example: https://github.com/scm-manager/plugin-center/blob/master/src/plugins/scm-teamscale-plugin/index.md diff --git a/pom.xml b/pom.xml index 2054116a65..f806be11d7 100644 --- a/pom.xml +++ b/pom.xml @@ -494,7 +494,7 @@ sonia.scm.maven smp-maven-plugin - 1.0.0-rc4 + 1.0.0-rc5 @@ -912,7 +912,7 @@ 2.1.1 4.5.2.Final 1.19.4 - 2.10.2 + 2.10.3 4.2.2 2.3.1 6.1.2.Final @@ -944,7 +944,7 @@ 8 UTF-8 SCM-MIT - + 1.3.1.Final diff --git a/scm-annotation-processor/pom.xml b/scm-annotation-processor/pom.xml index 4881cf3110..eafc3f5c58 100644 --- a/scm-annotation-processor/pom.xml +++ b/scm-annotation-processor/pom.xml @@ -78,7 +78,7 @@ org.kohsuke.metainf-services metainf-services - 1.7 + 1.8 diff --git a/scm-core/src/main/java/sonia/scm/web/api/RepositoryToHalMapper.java b/scm-core/src/main/java/sonia/scm/web/api/RepositoryToHalMapper.java new file mode 100644 index 0000000000..b5184fb202 --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/web/api/RepositoryToHalMapper.java @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.web.api; + +import de.otto.edison.hal.HalRepresentation; +import sonia.scm.repository.Repository; + +/** + * Maps a repository to a hal representation. + * This is especially useful if a plugin would deliver a repository to the frontend. + * + * @since 2.0.0 + */ +public interface RepositoryToHalMapper { + + /** + * Returns the hal representation of the repository. + * + * @param repository repository to map + * @return hal representation + */ + HalRepresentation map(Repository repository); +} diff --git a/scm-core/src/main/java/sonia/scm/web/filter/PermissionFilter.java b/scm-core/src/main/java/sonia/scm/web/filter/PermissionFilter.java index a254edcb41..9cfa95c1d5 100644 --- a/scm-core/src/main/java/sonia/scm/web/filter/PermissionFilter.java +++ b/scm-core/src/main/java/sonia/scm/web/filter/PermissionFilter.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.web.filter; import org.apache.shiro.SecurityUtils; @@ -35,7 +35,7 @@ import sonia.scm.repository.Repository; import sonia.scm.repository.RepositoryPermissions; import sonia.scm.repository.spi.ScmProviderHttpServlet; import sonia.scm.repository.spi.ScmProviderHttpServletDecorator; -import sonia.scm.security.Role; +import sonia.scm.security.Authentications; import sonia.scm.security.ScmSecurityException; import sonia.scm.util.HttpUtil; @@ -177,7 +177,7 @@ public abstract class PermissionFilter extends ScmProviderHttpServletDecorator HttpServletResponse response, Subject subject) throws IOException { - if (subject.hasRole(Role.USER)) + if (!Authentications.isAuthenticatedSubjectAnonymous()) { sendNotEnoughPrivilegesError(request, response); } diff --git a/scm-core/src/test/java/sonia/scm/web/filter/PermissionFilterTest.java b/scm-core/src/test/java/sonia/scm/web/filter/PermissionFilterTest.java index ad21e501e7..5ba99bd2f1 100644 --- a/scm-core/src/test/java/sonia/scm/web/filter/PermissionFilterTest.java +++ b/scm-core/src/test/java/sonia/scm/web/filter/PermissionFilterTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.web.filter; import com.github.sdorra.shiro.ShiroRule; @@ -82,6 +82,17 @@ public class PermissionFilterTest { permissionFilter.service(request, response, REPOSITORY); + verify(response).sendError(eq(403)); + verify(delegateServlet, never()).service(request, response, REPOSITORY); + } + + @Test + @SubjectAware(username = "_anonymous", password = "secret") + public void shouldBlockForAnonymousOnWriteRequestWithAuthenticationRequest() throws IOException, ServletException { + writeRequest = true; + + permissionFilter.service(request, response, REPOSITORY); + verify(response).sendError(eq(401), anyString()); verify(delegateServlet, never()).service(request, response, REPOSITORY); } diff --git a/scm-core/src/test/resources/sonia/scm/shiro.ini b/scm-core/src/test/resources/sonia/scm/shiro.ini index fda268ec83..4bd34d3a41 100644 --- a/scm-core/src/test/resources/sonia/scm/shiro.ini +++ b/scm-core/src/test/resources/sonia/scm/shiro.ini @@ -4,6 +4,7 @@ admin = secret, admin writer = secret, repo_write reader = secret, repo_read unpriv = secret +_anonymous = secret [roles] admin = * diff --git a/scm-ui/tsconfig/tsconfig.json b/scm-ui/tsconfig/tsconfig.json index a2450080eb..1c3acc4351 100644 --- a/scm-ui/tsconfig/tsconfig.json +++ b/scm-ui/tsconfig/tsconfig.json @@ -59,6 +59,10 @@ /* Experimental Options */ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - "skipLibCheck": true + "skipLibCheck": true, + "lib": [ + "dom", + "es2019" + ] } } diff --git a/scm-ui/ui-components/.storybook/config.js b/scm-ui/ui-components/.storybook/config.js index bfaea0245c..ae409e6478 100644 --- a/scm-ui/ui-components/.storybook/config.js +++ b/scm-ui/ui-components/.storybook/config.js @@ -70,7 +70,4 @@ addDecorator( }) ); -const RoutingDecorator = (story) => {story()}; -addDecorator(RoutingDecorator); - configure(require.context("../src", true, /\.stories\.tsx?$/), module); diff --git a/scm-ui/ui-components/src/CardColumn.tsx b/scm-ui/ui-components/src/CardColumn.tsx index 8931fe6a1e..42c1512690 100644 --- a/scm-ui/ui-components/src/CardColumn.tsx +++ b/scm-ui/ui-components/src/CardColumn.tsx @@ -27,7 +27,7 @@ import styled from "styled-components"; import { Link } from "react-router-dom"; type Props = { - title: string; + title: ReactNode; description?: string; avatar: ReactNode; contentRight?: ReactNode; @@ -99,9 +99,7 @@ export default class CardColumn extends React.Component {
-

- {title} -

+

{title}

{description}

{contentRight} diff --git a/scm-ui/ui-components/src/DateFromNow.test.ts b/scm-ui/ui-components/src/DateFromNow.test.ts index 8571864639..19acc08fda 100644 --- a/scm-ui/ui-components/src/DateFromNow.test.ts +++ b/scm-ui/ui-components/src/DateFromNow.test.ts @@ -25,7 +25,6 @@ import { chooseLocale, supportedLocales } from "./DateFromNow"; describe("test choose locale", () => { - it("should choose de", () => { const locale = chooseLocale("de_DE", ["de", "en"]); expect(locale).toBe(supportedLocales.de); @@ -45,5 +44,4 @@ describe("test choose locale", () => { const locale = chooseLocale("af", ["af", "be"]); expect(locale).toBe(supportedLocales.en); }); - }); diff --git a/scm-ui/ui-components/src/MarkdownView.stories.tsx b/scm-ui/ui-components/src/MarkdownView.stories.tsx index 464efe42cc..e43f9afd75 100644 --- a/scm-ui/ui-components/src/MarkdownView.stories.tsx +++ b/scm-ui/ui-components/src/MarkdownView.stories.tsx @@ -32,12 +32,14 @@ import MarkdownXmlCodeBlock from "./__resources__/markdown-xml-codeblock.md"; import MarkdownInlineXml from "./__resources__/markdown-inline-xml.md"; import Title from "./layout/Title"; import { Subtitle } from "./layout"; +import { MemoryRouter } from "react-router-dom"; const Spacing = styled.div` padding: 2em; `; storiesOf("MarkdownView", module) + .addDecorator(story => {story()}) .addDecorator(story => {story()}) .add("Default", () => ) .add("Code without Lang", () => ) diff --git a/scm-ui/ui-components/src/__resources__/git-logo.png b/scm-ui/ui-components/src/__resources__/git-logo.png new file mode 100644 index 0000000000..ed9393dc36 Binary files /dev/null and b/scm-ui/ui-components/src/__resources__/git-logo.png differ diff --git a/scm-ui/ui-components/src/__resources__/repository.ts b/scm-ui/ui-components/src/__resources__/repository.ts new file mode 100644 index 0000000000..8facf86e57 --- /dev/null +++ b/scm-ui/ui-components/src/__resources__/repository.ts @@ -0,0 +1,67 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +export default { + contact: "heart-of-gold@hitchhiher.com", + creationDate: "2020-03-23T08:26:01.164Z", + description: "The starship Heart of Gold was the first spacecraft to make use of the Infinite Improbability Drive", + healthCheckFailures: [], + lastModified: "2020-03-23T08:26:01.876Z", + namespace: "hitchhiher", + name: "heartOfGold", + type: "git", + _links: { + self: { href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git" }, + delete: { href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git" }, + update: { href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git" }, + permissions: { href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git/permissions/" }, + protocol: [ + { href: "ssh://scmadmin@localhost:4567/repo/scmadmin/Git", name: "ssh" }, + { href: "http://localhost:8081/scm/repo/scmadmin/Git", name: "http" } + ], + tags: { href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git/tags/" }, + branches: { href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git/branches/" }, + incomingChangesets: { + href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git/incoming/{source}/{target}/changesets", + templated: true + }, + incomingDiff: { + href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git/incoming/{source}/{target}/diff", + templated: true + }, + incomingDiffParsed: { + href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git/incoming/{source}/{target}/diff/parsed", + templated: true + }, + changesets: { href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git/changesets/" }, + sources: { href: "http://localhost:8081/scm/api/v2/repositories/scmadmin/Git/sources/" }, + authorMappingConfig: { + href: "http://localhost:8081/scm/api/v2/authormapping/configuration/scmadmin/Git" + }, + unfavorize: { href: "http://localhost:8081/scm/api/v2/unfavorize/scmadmin/Git" }, + favorites: [ + { href: "http://localhost:8081/scm/api/v2/unfavorize/scmadmin/Git", name: "unfavorize" }, + { href: "http://localhost:8081/scm/api/v2/favorize/scmadmin/Git", name: "favorize" } + ] + } +}; diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index 790dc01249..0417014428 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -34188,6 +34188,684 @@ exports[`Storyshots MarkdownView Xml Code Block 1`] = `
`; +exports[`Storyshots Navigation|Secondary Default 1`] = ` +
+
+ +
+
+`; + +exports[`Storyshots Navigation|Secondary Extension Point 1`] = ` +
+
+ +
+
+`; + +exports[`Storyshots Navigation|Secondary Sub Navigation 1`] = ` +
+
+ +
+
+`; + +exports[`Storyshots RepositoryEntry Avatar EP 1`] = ` + +`; + +exports[`Storyshots RepositoryEntry Before Title EP 1`] = ` + +`; + +exports[`Storyshots RepositoryEntry Default 1`] = ` + +`; + +exports[`Storyshots RepositoryEntry Quick Link EP 1`] = ` + +`; + exports[`Storyshots SyntaxHighlighter Go 1`] = `
ReactNode) => {story()}; +const RoutingDecorator = (story: () => ReactNode) => {story()}; storiesOf("Buttons|Button", module) + .addDecorator(RoutingDecorator) .add("Colors", () => (
{colors.map(color => ( @@ -70,6 +73,7 @@ storiesOf("Buttons|Button", module) const buttonStory = (name: string, storyFn: () => ReactElement) => { return storiesOf("Buttons|" + name, module) + .addDecorator(RoutingDecorator) .addDecorator(SpacingDecorator) .add("Default", storyFn); }; diff --git a/scm-ui/ui-components/src/forms/Checkbox.stories.tsx b/scm-ui/ui-components/src/forms/Checkbox.stories.tsx index 32112d97a1..9f714e5af0 100644 --- a/scm-ui/ui-components/src/forms/Checkbox.stories.tsx +++ b/scm-ui/ui-components/src/forms/Checkbox.stories.tsx @@ -42,4 +42,3 @@ storiesOf("Forms|Checkbox", module) )); - diff --git a/scm-ui/ui-components/src/forms/Checkbox.tsx b/scm-ui/ui-components/src/forms/Checkbox.tsx index 00f6285423..70888cf483 100644 --- a/scm-ui/ui-components/src/forms/Checkbox.tsx +++ b/scm-ui/ui-components/src/forms/Checkbox.tsx @@ -54,7 +54,7 @@ export default class Checkbox extends React.Component { if (title) { return ; } - } + }; render() { const { label, checked, disabled } = this.props; @@ -68,13 +68,7 @@ export default class Checkbox extends React.Component { but bulma does. // @ts-ignore */}
diff --git a/scm-ui/ui-components/src/forms/Radio.tsx b/scm-ui/ui-components/src/forms/Radio.tsx index d05e40a19a..fe6a35f4a6 100644 --- a/scm-ui/ui-components/src/forms/Radio.tsx +++ b/scm-ui/ui-components/src/forms/Radio.tsx @@ -25,7 +25,6 @@ import React, { ChangeEvent } from "react"; import { Help } from "../index"; import styled from "styled-components"; - const StyledRadio = styled.label` margin-right: 0.5em; `; diff --git a/scm-ui/ui-components/src/forms/Textarea.stories.tsx b/scm-ui/ui-components/src/forms/Textarea.stories.tsx index 2698195519..bcb638cbaa 100644 --- a/scm-ui/ui-components/src/forms/Textarea.stories.tsx +++ b/scm-ui/ui-components/src/forms/Textarea.stories.tsx @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -import React, {useState} from "react"; +import React, { useState } from "react"; import { storiesOf } from "@storybook/react"; import styled from "styled-components"; import Textarea from "./Textarea"; diff --git a/scm-ui/ui-components/src/layout/Footer.stories.tsx b/scm-ui/ui-components/src/layout/Footer.stories.tsx index 02738f68c0..c25b618a87 100644 --- a/scm-ui/ui-components/src/layout/Footer.stories.tsx +++ b/scm-ui/ui-components/src/layout/Footer.stories.tsx @@ -33,6 +33,7 @@ import hitchhiker from "../__resources__/hitchhiker.png"; import marvin from "../__resources__/marvin.jpg"; import NavLink from "../navigation/NavLink"; import ExternalLink from "../navigation/ExternalLink"; +import { MemoryRouter } from "react-router-dom"; const trillian: Me = { name: "trillian", @@ -64,6 +65,7 @@ const withBinder = (binder: Binder) => { }; storiesOf("Layout|Footer", module) + .addDecorator(story => {story()}) .add("Default", () => { return