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

Multiple project owner backend #4774

Merged

Conversation

aryan-bhokare
Copy link
Contributor

@aryan-bhokare aryan-bhokare commented Jul 18, 2024

closes #3958 #4161

Proposed changes

Work done:

  1. Modification of db schema.
  2. Addition of new API GetProjectOwners.
  3. Modifications of SendInvitation API.
  4. Modifications of LeaveProject API.
  5. Added new API UpdateMemberRole.
  6. Added new API DeleteProject.

Types of changes

What types of changes does your code introduce to Litmus? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Dependency

  • Please add the links to the dependent PR need to be merged before this (if any).

Special notes for your reviewer:

aryan-bhokare and others added 21 commits March 17, 2024 12:19
Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
…itmuschaos#4527)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.18.0 to 0.21.0.
- [Commits](golang/crypto@v0.18.0...v0.21.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.5 to 1.15.6.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.15.5...v1.15.6)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [github.com/golang/protobuf](https://github.com/golang/protobuf) from 1.5.3 to 1.5.4.
- [Release notes](https://github.com/golang/protobuf/releases)
- [Commits](golang/protobuf@v1.5.3...v1.5.4)

---
updated-dependencies:
- dependency-name: github.com/golang/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Raj Das <mail.rajdas@gmail.com>
This modification unables to send invite with the role as owner.

Signed-off-by: aryan <aryan1bhokare@gmail.com>
This modification checks if the User is the last owner of the project and if not User can leave the project.

Signed-off-by: aryan <aryan1bhokare@gmail.com>
Allows Owner to be able to leave the project.

Signed-off-by: aryan <aryan1bhokare@gmail.com>
This API is used for updating role of the member in the project.

Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
Owner can delete project with help of this API.

Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
…kend

Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
User cannot change role of their own, so that it will avoid edge cases like
1. User is the last owner of the project.
2. User accidentally losing owner access to the projects.

Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com>
var project struct {
Members []*entities.Member `bson:"members"`
}
err := r.Collection.FindOne(context.TODO(), filter).Decode(&project)

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query depends on a
user-provided value
.
This query depends on a
user-provided value
.
query := bson.D{{"_id", projectID}}
update := bson.D{{"$set", bson.M{"members.$[elem].role": role}}}

_, err := r.Collection.UpdateOne(context.TODO(), query, update, opts)

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query depends on a
user-provided value
.
func (r repository) DeleteProject(projectID string) error {
query := bson.D{{"_id", projectID}}

result, err := r.Collection.DeleteOne(context.TODO(), query)

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query depends on a
user-provided value
.
Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: aryan <aryan1bhokare@gmail.com>
@Saranya-jena Saranya-jena merged commit 164e280 into litmuschaos:master Jul 22, 2024
17 of 18 checks passed
andoriyaprashant pushed a commit to andoriyaprashant/litmus that referenced this pull request Sep 7, 2024
* Modified db schema of Owner.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added new API GetProjectOwners.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* fix: return type error.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* chore(deps): Bump golang.org/x/crypto in /chaoscenter/authentication (litmuschaos#4527)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.18.0 to 0.21.0.
- [Commits](golang/crypto@v0.18.0...v0.21.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump follow-redirects in /chaoscenter/web (litmuschaos#4529)

Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.5 to 1.15.6.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.15.5...v1.15.6)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump github.com/golang/protobuf (litmuschaos#4493)

Bumps [github.com/golang/protobuf](https://github.com/golang/protobuf) from 1.5.3 to 1.5.4.
- [Release notes](https://github.com/golang/protobuf/releases)
- [Commits](golang/protobuf@v1.5.3...v1.5.4)

---
updated-dependencies:
- dependency-name: github.com/golang/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Raj Das <mail.rajdas@gmail.com>

* Modified SendInvitation API.

This modification unables to send invite with the role as owner.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Modified LeaveProject API.

This modification checks if the User is the last owner of the project and if not User can leave the project.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* RBAC modification `LeaveProject`.

Allows Owner to be able to leave the project.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added `UpdateMemberRole` API.

This API is used for updating role of the member in the project.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Fixed some syntax errors.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Updated roles for owner.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added new API `DeleteProject`.
Owner can delete project with help of this API.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added mocks.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* modified go.sum

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added condition `UpdateMemberRole`.

User cannot change role of their own, so that it will avoid edge cases like
1. User is the last owner of the project.
2. User accidentally losing owner access to the projects.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* made suggested changes.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Changed DeleteProject endpoint to have url parameter.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Minor fixes.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* fixed import orders

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* fixing RoleEditor to RoleExecuter

Signed-off-by: aryan <aryan1bhokare@gmail.com>

---------

Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Raj Das <mail.rajdas@gmail.com>
Co-authored-by: Saranya Jena <saranya.jena@harness.io>
Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
andoriyaprashant pushed a commit to andoriyaprashant/litmus that referenced this pull request Sep 7, 2024
* Modified db schema of Owner.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added new API GetProjectOwners.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* fix: return type error.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* chore(deps): Bump golang.org/x/crypto in /chaoscenter/authentication (litmuschaos#4527)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.18.0 to 0.21.0.
- [Commits](golang/crypto@v0.18.0...v0.21.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump follow-redirects in /chaoscenter/web (litmuschaos#4529)

Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.5 to 1.15.6.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.15.5...v1.15.6)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump github.com/golang/protobuf (litmuschaos#4493)

Bumps [github.com/golang/protobuf](https://github.com/golang/protobuf) from 1.5.3 to 1.5.4.
- [Release notes](https://github.com/golang/protobuf/releases)
- [Commits](golang/protobuf@v1.5.3...v1.5.4)

---
updated-dependencies:
- dependency-name: github.com/golang/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Raj Das <mail.rajdas@gmail.com>

* Modified SendInvitation API.

This modification unables to send invite with the role as owner.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Modified LeaveProject API.

This modification checks if the User is the last owner of the project and if not User can leave the project.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* RBAC modification `LeaveProject`.

Allows Owner to be able to leave the project.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added `UpdateMemberRole` API.

This API is used for updating role of the member in the project.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Fixed some syntax errors.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Updated roles for owner.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added new API `DeleteProject`.
Owner can delete project with help of this API.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added mocks.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* modified go.sum

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Added condition `UpdateMemberRole`.

User cannot change role of their own, so that it will avoid edge cases like
1. User is the last owner of the project.
2. User accidentally losing owner access to the projects.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* made suggested changes.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Changed DeleteProject endpoint to have url parameter.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* Minor fixes.

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* fixed import orders

Signed-off-by: aryan <aryan1bhokare@gmail.com>

* fixing RoleEditor to RoleExecuter

Signed-off-by: aryan <aryan1bhokare@gmail.com>

---------

Signed-off-by: aryan <aryan1bhokare@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Raj Das <mail.rajdas@gmail.com>
Co-authored-by: Saranya Jena <saranya.jena@harness.io>
Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support multiple project owners
3 participants