Skip to content
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

Add function to archive repository #2595

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

onukura
Copy link
Member

@onukura onukura commented Nov 11, 2020

Before submitting a pull-request to GitBucket I have first:

  • read the contribution guidelines
  • rebased my branch over master
  • verified that project is compiling
  • verified that tests are passing
  • squashed my commits as appropriate (keep several commits if it is relevant to understand the PR)
  • marked as closed using commit message all issue ID that this PR should correct

About this PR

This PR add feature to archive repository (read-only). This resolves #2152.

Intended Behavior

If repo is archived,

  • user can read repo. only except public/private setting.
  • buttons or input area related to repo. update action will be invisible.
  • API end points related to repo. update action will be unavailable.

Technical changes

  • Add ARCHIVED column to REPOSITORY table. => use like repositpry.repository.isArchived
  • Introduce UnarchivedAuthenticator to reject request on server side if repo. is archived.
  • Leave activity log when repo archive statement is changed.

Screenshot

pr_screenshot_list

@onukura onukura marked this pull request as ready for review November 15, 2020 13:37
@onukura onukura requested a review from takezoe December 7, 2020 15:01
src/main/resources/update/gitbucket-core_4.35.xml Outdated Show resolved Hide resolved
/**
* Allow action on only unarchived repository
*/
trait UnarchivedAuthenticator { self: ControllerBase with RepositoryService =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will have to ensure applying this authenticator to all possible write actions even in plugins, but ensuring it in all plugins is actually difficult or impossible.

One idea I came up with is that checking whether a repository is archived in writableUsersOnly too. This is redundant and don't cover all cases, but will automatically apply the minimum protection for the existing plugins. Or adding an option like allowUnarchivedRepository to all authenticator so that all actions currently use authenticator will need to be updated to specify that option explicitly.

Anyway, we would need to consider more carefully about how to apply the protection for archived repositories.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@takezoe Thanks for you review! I agree that applying UnarchivedAuthenticator to all write action is difficult and impossible.

checking whether a repository is archived in writableUsersOnly

That might be simple and good solution, but actually checking in writableUserOnly is not enough. Sometime we want to restrict even readableUserOnly user action if repository is archived such as "create new issue".

adding an option like allowUnarchivedRepository to all authenticator so that all actions currently use authenticator will need to be updated to specify that option explicitly.

It is more flexible than checking in writableUsersOnly, but as you said need update all actions, and even plugins...

hmm...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking whether a repository is archived in writableUsersOnly too

@takezoe I misunderstood what you meant about this. You mean check if repository is archived in writableUsersOnly and use UnarchivedAuthenticator for other cases such as "create new issue" (readableUserOnly) if restriction required.

In that case this idea sound better because it "will automatically apply the minimum protection for the existing plugins" as you said.

Copy link
Member

@takezoe takezoe Dec 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is what I meant. But that is also just one option. We would need to see more closely and consider possible options carefully to figure out what is the best way for this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need to see more closely and consider possible options carefully to figure out what is the best way for this.

@takezoe Yeah. I agree with that.

BTW I updated PR 6653dbb, 89de8fd because checking in writableUsersOnly too sounds better than before at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Freeze repository (make repository read-only)
2 participants