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

Sy 877 server api middleware #731

Merged
merged 35 commits into from
Jul 26, 2024
Merged

Sy 877 server api middleware #731

merged 35 commits into from
Jul 26, 2024

Conversation

LeonLiur
Copy link
Contributor

@LeonLiur LeonLiur commented Jul 18, 2024

Feature Pull Request Template

Key Information

Description

API middleware & client libraries supporting user registration and policy management.

Please review and consider these three questions I had while in development:

  • In our typescript client, the auth field can be undefined if the user did not provide username & password upon starting the client. Should this still be the case? Shouldn't we allow auth to always be an available service so the user can register even if they did not log in?
  • Should register be a public route? This is fine because even if a user registers itself, it does not have the privilege to do anything else. However this might leave vulnerabilities like DDoS? (which we can address in other ways than making it a private endpoint).
  • Minor security issue: If a user has channel CREATE privileges but not RETRIEVE, they can still RETRIEVE channels they created because of the client's channel cache. Is this worth addressing?

Basic Readiness Checklist

  • I have performed a self-review of my code.
  • I have added relevant tests to cover the changes.
  • I have updated user facing documentation accordingly.

Migrations

  • Console - I have ensured that previous versions of stored data structures are
    properly migrated to new formats.
  • Server - I have ensured that previous versions of stored data structures are
    properly migrated to new formats.

Manual QA Additions

  • I have updated the Release Candidate template
    with necessary manual QA steps to test my change.

Breaking Changes

/api/v1/auth/protected/change-password -> /api/v1/user/protected/change-password
/api/v1/auth/protected/change-username -> /api/v1/user/protected/change-username
/api/v1/auth/register -> /api/v1/user/register

Copy link

vercel bot commented Jul 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2024 6:13pm

Copy link

codecov bot commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 35.24138% with 939 lines in your changes missing coverage. Please review.

Project coverage is 50.98%. Comparing base (0ae52e0) to head (f106c83).

Files Patch % Lines
synnax/pkg/api/framer.go 0.00% 150 Missing ⚠️
synnax/pkg/api/ranger.go 0.00% 105 Missing ⚠️
synnax/pkg/api/hardware.go 0.00% 76 Missing ⚠️
synnax/pkg/api/user.go 0.00% 70 Missing ⚠️
synnax/pkg/api/access.go 0.00% 61 Missing ⚠️
synnax/pkg/api/ontology.go 0.00% 61 Missing ⚠️
synnax/pkg/api/channel.go 0.00% 55 Missing ⚠️
synnax/pkg/api/schematic.go 0.00% 49 Missing ⚠️
synnax/pkg/api/line_plot.go 0.00% 39 Missing ⚠️
synnax/pkg/api/label.go 0.00% 38 Missing ⚠️
... and 37 more
Additional details and impacted files
@@            Coverage Diff             @@
##               rc     #731      +/-   ##
==========================================
- Coverage   51.31%   50.98%   -0.34%     
==========================================
  Files        1055     1066      +11     
  Lines       81142    82146    +1004     
  Branches     3288     3297       +9     
==========================================
+ Hits        41638    41880     +242     
- Misses      38484    39258     +774     
+ Partials     1020     1008      -12     
Flag Coverage Δ
aspen 50.18% <ø> (ø)
cesium 76.18% <ø> (ø)
clientpy 81.97% <100.00%> (ø)
clientts 87.56% <96.83%> (+0.49%) ⬆️
freighterpy 77.81% <100.00%> (ø)
pluto 44.74% <0.00%> (+<0.01%) ⬆️
synnax 27.10% <8.15%> (-1.75%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@emilbon99 emilbon99 left a comment

Choose a reason for hiding this comment

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

See my comments. Also, please do a review of all endpoints to make sure we're not accidentally leaking information by using named return values after checking access.

client/py/synnax/ontology/id.py Outdated Show resolved Hide resolved
client/ts/package.json Outdated Show resolved Hide resolved
client/py/synnax/auth.py Outdated Show resolved Hide resolved
synnax/cmd/start.go Outdated Show resolved Hide resolved
client/py/synnax/ontology/__init__.py Outdated Show resolved Hide resolved
client/ts/src/auth/auth.ts Outdated Show resolved Hide resolved
ctx context.Context,
req AccessRetrievePolicyRequest,
) (res AccessRetrievePolicyResponse, err error) {
res.Policies = make([]rbac.Policy, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Useless allocation. Just use nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this is nil then upon encoding as json it won't get encoded into an empty list

@emilbon99
Copy link
Contributor

Note that Pluto tests do not pass because the client does not compile due to type errors

@LeonLiur
Copy link
Contributor Author

Note that Pluto tests do not pass because the client does not compile due to type errors

addressed

synnax/cmd/start.go Outdated Show resolved Hide resolved
synnax/pkg/distribution/channel/channel.go Outdated Show resolved Hide resolved
pnpm-lock.yaml Show resolved Hide resolved
synnax/pkg/access/rbac/policy.go Show resolved Hide resolved
synnax/pkg/access/rbac/policy.go Outdated Show resolved Hide resolved
synnax/pkg/api/api.go Outdated Show resolved Hide resolved
synnax/pkg/api/channel_test.go Show resolved Hide resolved
Copy link
Contributor

@emilbon99 emilbon99 left a comment

Choose a reason for hiding this comment

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

Address my comments. Also freighter test is failing - flaky or did the formatting tests mess something up?

client/ts/src/user/client.ts Outdated Show resolved Hide resolved
client/ts/src/user/client.ts Outdated Show resolved Hide resolved
synnax/pkg/access/rbac/policy.go Show resolved Hide resolved
synnax/pkg/api/http/http.go Show resolved Hide resolved
synnax/pkg/api/user.go Show resolved Hide resolved
@LeonLiur
Copy link
Contributor Author

Address my comments. Also freighter test is failing - flaky or did the formatting tests mess something up?

Seemed flakey, passing now

client/py/tests/conftest.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Lham42 Lham42 left a comment

Choose a reason for hiding this comment

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

Is there functionality here we should also test in QA?

@LeonLiur
Copy link
Contributor Author

Is there functionality here we should also test in QA?

Yes, we should probably test the ability to register new users

@emilbon99
Copy link
Contributor

@LeonLiur @Lham42 We'll probably add QA changes with @pjdotson goes through and implements the console stuff. The changes in this PR can all be easily unit tested.

Copy link
Contributor

@Lham42 Lham42 left a comment

Choose a reason for hiding this comment

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

LGTM

@LeonLiur LeonLiur merged commit d9fa728 into rc Jul 26, 2024
46 of 49 checks passed
@LeonLiur LeonLiur deleted the sy-877-server-api-middleware branch July 26, 2024 18:41
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.

4 participants