Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Support read-only access to repositories #159

Merged
merged 1 commit into from
Aug 30, 2014

Conversation

scorphus
Copy link
Contributor

Regarding the repository.Repository struct:

  • Repository.Users: users that with write access
  • Repository.ReadOnlyUsers: users with read-only access

Implementation notes:

  • When creating a new repository specify which users should be
    allowed read access
  • Allow specifying if read-only access when adding user to repo
  • When removing user from repo, remove from both write and read
    collections of users

Please review, comment, suggest and advise! 😉

@scorphus
Copy link
Contributor Author

Oh... I forgot the docs! 😯 Hold on... 😀

@scorphus
Copy link
Contributor Author

Done! 👍

if err := repository.GrantAccess(repositories, users); err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
if readonly == "yes" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the repository package should encapulate the readonly logic and the api should repass if the grant is full or readonly:

readonly := r.URL.Query().Get("readonly") == "true"
repository.GrantAccess(repositories, users, readonly)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about that too but decided to go exactly the opposite way: the repository being agnostic as per:

“I'm a repository. Concerning my users, I just manage two collections, Users and ReadOnlyUsers, with read/write and read-only accesses respectively. These are the methods to operate on each of them, separately: GrantAccess, RevokeAccess, GrantReadOnlyAccess and RevokeReadOnlyAccess.

@scorphus
Copy link
Contributor Author

I've just rebased the changes on top of master until we decide the best way to implement this 😉

Regarding the repository.Repository struct:

* `Repository.Users`: users that with write access
* `Repository.ReadOnlyUsers`: users with read-only access

Implementation notes:

* When creating a new repository specify which users should be
  allowed read access
* Allow specifying if read-only access when adding user to repo
* When removing user from repo, remove from both write and read
collections of users
@scorphus
Copy link
Contributor Author

@fsouza wrote:

@andrewsmedina what if someone wants to remove just write access?

Two requests are necessary to achieve this:

  1. Revoke access
  2. Grant read-only access

andrewsmedina added a commit that referenced this pull request Aug 30, 2014
Support read-only access to repositories
@andrewsmedina andrewsmedina merged commit 28f1e86 into tsuru:master Aug 30, 2014
@andrewsmedina
Copy link
Contributor

@scorphus thank you!

@scorphus scorphus deleted the read-only-users branch August 31, 2014 14:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants