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

SMQ-2604 - Change PAT repo implementation #2680

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

nyagamunene
Copy link
Contributor

What type of PR is this?

What does this do?

Which issue(s) does this PR fix/relate to?

Have you included tests for your changes?

Did you document any new/modified feature?

Notes

@nyagamunene nyagamunene marked this pull request as ready for review February 4, 2025 14:25
@nyagamunene nyagamunene requested a review from a team as a code owner February 4, 2025 14:25
@dborovcanin
Copy link
Collaborator

@nyagamunene Please address comments @arvindh123 left.

@nyagamunene nyagamunene force-pushed the MG-2604 branch 2 times, most recently from 32b153e to d5d9b8e Compare February 12, 2025 20:48
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 8.41960% with 1327 lines in your changes missing coverage. Please review.

Project coverage is 35.34%. Comparing base (da6e3e1) to head (a33fd89).

Files with missing lines Patch % Lines
auth/postgres/repo.go 0.00% 368 Missing ⚠️
channels/middleware/authorization.go 0.00% 110 Missing ⚠️
auth/pat.go 0.00% 91 Missing ⚠️
groups/middleware/authorization.go 0.00% 84 Missing ⚠️
clients/middleware/authorization.go 0.00% 72 Missing ⚠️
auth/service.go 4.10% 70 Missing ⚠️
auth/postgres/pat.go 0.00% 65 Missing ⚠️
users/middleware/authorization.go 0.00% 65 Missing ⚠️
auth/mocks/cache.go 0.00% 54 Missing ⚠️
auth/api/logging.go 0.00% 43 Missing ⚠️
... and 10 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2680      +/-   ##
==========================================
- Coverage   42.08%   35.34%   -6.75%     
==========================================
  Files         341      238     -103     
  Lines       47488    38794    -8694     
==========================================
- Hits        19987    13710    -6277     
+ Misses      25318    24000    -1318     
+ Partials     2183     1084    -1099     

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

auth/pat.go Outdated
Comment on lines 238 to 243
PatId string
OptionalDomainId string `json:"optional_domain_id,omitempty"`
EntityType EntityType `json:"entity_type,omitempty"`
EntityId string `json:"entity_id,omitempty"`
Operation Operation `json:"operation,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we have a scope this complex? Can we have it embedded entity types and operations only?

Comment on lines 32 to 36
key := GenerateKey(sc.PatID, sc.OptionalDomainID, sc.EntityType, sc.Operation, sc.EntityID)
if err := pc.client.Set(ctx, key, true, pc.duration).Err(); err != nil {
return errors.Wrap(repoerr.ErrCreateEntity, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets add entityID to key and value as only True
pc.client.Set(ctx, key, true, 0).Err()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lets add entityID to key and value as only True pc.client.Set(ctx, key, true, 0).Err()

The pc.duration is the time it takes before it expires in the RAM. By setting it to 0 it will never expire. Should this be the case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's have pc.Duration, Don't set to 0, I just gave an example to for key

Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
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.

Change PATs repo implementation
3 participants