Skip to content

Space aware 1 on 1#47981

Merged
fantapsody merged 18 commits intoelastic:masterfrom
fantapsody:space_aware_1_on_1
Oct 17, 2019
Merged

Space aware 1 on 1#47981
fantapsody merged 18 commits intoelastic:masterfrom
fantapsody:space_aware_1_on_1

Conversation

@fantapsody
Copy link

@fantapsody fantapsody commented Oct 11, 2019

Related issue https://github.com/elastic/code/issues/838

For APIs related to repository, file, and search, user should only see
contents from repositories belongs to his/her space.

One repository can only exists in the space where it is imported.

Summary

Summarize your PR. If it involves visual changes include a screenshot or gif.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@fantapsody fantapsody self-assigned this Oct 11, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/code (Team:Code)

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@kobelb kobelb left a comment

Choose a reason for hiding this comment

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

The parts of the code which are using the RepositoryReferenceHelper to enforce space-awareness look good! How confident are you that all data-access is consuming the RepositoryReferenceHelper appropriately?

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't a "security issue", but other errors can be thrown in this situation which will be ignored.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, the error handling is refined in new commits.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@fantapsody
Copy link
Author

The parts of the code which are using the RepositoryReferenceHelper to enforce space-awareness look good! How confident are you that all data-access is consuming the RepositoryReferenceHelper appropriately?

I have added checks on all code REST APIs having accesses to repositories, files, status, and LSPs to make sure only requests from the space with a reference to the repository can have privileges to access. It seems to be proper and complete to me, and I have requested reviews from other backend developers to confirm this.

Copy link
Contributor

@mw-ding mw-ding left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, one minor comment inline. please wait for @kobelb's approval here.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we wrap this repeated code lines in to a function?

Copy link
Author

Choose a reason for hiding this comment

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

I have refined the related code, please check if it is better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you. It looks great!

Yang Yang added 9 commits October 16, 2019 11:57
For APIs related to repository, file, and search, user should only see
contents from repositories belongs to his/her space.

When the same repository is added in different spaces, they should point
to the same underlying repository. We use references from spaces to
repositories to represent this relationship.

- after importing a repo R in a space S, a reference is added between R
and S.
- after deleting a repo R in a space S, the reference between R and S is
removed.
- a repo is imported and cloned after the first reference to it is
added.
- a repo is deleted after the last reference to it is removed.
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@kobelb kobelb left a comment

Choose a reason for hiding this comment

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

LGTM on the condition that the Code team is sure that the authorization checks are implemented everywhere they should be. It'd make me feel much more comfortable if we implemented some type of abstraction which would perform the appropriate authorization directly prior to the data-access. This is what we do for Saved Objects in general, so it's easier to be confident that authorization is being done in all of the proper places.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@fantapsody
Copy link
Author

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@fantapsody fantapsody merged commit 95181cf into elastic:master Oct 17, 2019
@fantapsody fantapsody deleted the space_aware_1_on_1 branch October 17, 2019 05:56
fantapsody pushed a commit that referenced this pull request Oct 17, 2019
* [Code] makes Code space aware.

For APIs related to repository, file, and search, user should only see
contents from repositories belongs to his/her space.

When the same repository is added in different spaces, they should point
to the same underlying repository. We use references from spaces to
repositories to represent this relationship.

This patch implements the 1:1 model, which means a repository can only be imported in on space.
fantapsody pushed a commit that referenced this pull request Oct 17, 2019
* [Code] makes Code space aware.

For APIs related to repository, file, and search, user should only see
contents from repositories belongs to his/her space.

When the same repository is added in different spaces, they should point
to the same underlying repository. We use references from spaces to
repositories to represent this relationship.

This patch implements the 1:1 model, which means a repository can only be imported in on space.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants