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

feat: add org domain whitelisting #289

Merged
merged 9 commits into from
Aug 13, 2023
Merged

feat: add org domain whitelisting #289

merged 9 commits into from
Aug 13, 2023

Conversation

Chief-Rishab
Copy link
Member

@Chief-Rishab Chief-Rishab commented Aug 2, 2023

@vercel
Copy link

vercel bot commented Aug 2, 2023

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

Name Status Preview Comments Updated (UTC)
frontier ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 13, 2023 2:16pm

@coveralls
Copy link

coveralls commented Aug 2, 2023

Pull Request Test Coverage Report for Build 5842332694

  • 0 of 312 (0.0%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.2%) to 39.677%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/v1beta1/v1beta1.go 0 1 0.0%
cmd/serve.go 0 10 0.0%
internal/store/postgres/domain.go 0 11 0.0%
internal/store/postgres/domain_repository.go 0 141 0.0%
internal/api/v1beta1/domain.go 0 149 0.0%
Totals Coverage Status
Change from base Build 5840222929: -1.2%
Covered Lines: 4345
Relevant Lines: 10951

💛 - Coveralls

core/domain/domain.go Outdated Show resolved Hide resolved
core/domain/domain.go Outdated Show resolved Hide resolved
Comment on lines +3 to +4
name text NOT NULL,
org_id uuid NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
Copy link
Member

Choose a reason for hiding this comment

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

We can create a unique constraint on org_id and name. One index on org_id.

Comment on lines 256 to 266
"/raystack.frontier.v1beta1.FrontierService/ListOrganizationDomains": func(ctx context.Context, handler *v1beta1.Handler, req any) error {
pbreq := req.(*frontierv1beta1.ListOrganizationDomainsRequest)
return handler.IsAuthorized(ctx, schema.OrganizationNamespace, pbreq.GetOrgId(), schema.GetPermission)
},
"/raystack.frontier.v1beta1.FrontierService/GetOrganizationDomain": func(ctx context.Context, handler *v1beta1.Handler, req any) error {
pbreq := req.(*frontierv1beta1.GetOrganizationDomainRequest)
return handler.IsAuthorized(ctx, schema.OrganizationNamespace, pbreq.GetId(), schema.GetPermission)
},
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering about the authz model, if we expect user already part of the org to find possible orgs to join, how would he join it?

Copy link
Member Author

Choose a reason for hiding this comment

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

there's another API for that (get orgs by domain)

internal/store/postgres/domain_repository.go Show resolved Hide resolved
Token string
Verified bool
VerifiedAt time.Time
CreatedAt time.Time
Copy link
Member

Choose a reason for hiding this comment

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

How about having an expires at column as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

was thinking of keeping it abstract since all the verified domains will not require that field, the cron job can be just used to remove the pending state domains with created-at time being more than 7 days

core/domain/service.go Outdated Show resolved Hide resolved
core/domain/service.go Outdated Show resolved Hide resolved
cmd/serve.go Outdated Show resolved Hide resolved
core/domain/domain.go Outdated Show resolved Hide resolved
core/domain/service.go Outdated Show resolved Hide resolved
cmd/serve.go Show resolved Hide resolved
core/domain/filter.go Outdated Show resolved Hide resolved
internal/api/v1beta1/domain.go Outdated Show resolved Hide resolved
Comment on lines +31 to +32
InitDomainVerification(ctx context.Context) error
Close()
Copy link
Member

Choose a reason for hiding this comment

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

Are we calling these two here?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, in the server file to initialise and close the cron to remove the pending records for domain verification

Copy link
Member

Choose a reason for hiding this comment

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

In server file we work with actual struct instead of interface, can you confirm? I think we can remove Close.

internal/api/v1beta1/domain.go Show resolved Hide resolved
internal/store/postgres/domain.go Outdated Show resolved Hide resolved
internal/store/postgres/domain_repository.go Show resolved Hide resolved
Copy link
Member

@kushsharma kushsharma left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +31 to +32
InitDomainVerification(ctx context.Context) error
Close()
Copy link
Member

Choose a reason for hiding this comment

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

In server file we work with actual struct instead of interface, can you confirm? I think we can remove Close.

@kushsharma kushsharma merged commit 25ee189 into main Aug 13, 2023
6 checks passed
@kushsharma kushsharma deleted the feat/domain-whitelists branch August 13, 2023 16:27
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.

3 participants