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

fix: checking hosts properly #2945

Merged
merged 4 commits into from
Aug 16, 2022
Merged

fix: checking hosts properly #2945

merged 4 commits into from
Aug 16, 2022

Conversation

ssoroka
Copy link
Contributor

@ssoroka ssoroka commented Aug 15, 2022

Summary

Checklist

  • Wrote appropriate unit tests
  • Considered security implications of the change
  • Updated associated docs where necessary
  • Updated associated configuration where necessary
  • Change is backwards compatible if it needs to be (user can upgrade without manual steps?)
  • Nothing sensitive logged
  • Considered data migrations for smooth upgrades

Related Issues

Resolves #

@@ -71,12 +77,14 @@ func Signup(c *gin.Context, keyExpiresAt time.Time, details SignupDetails) (*mod
Resource: ResourceInfraAPI,
CreatedBy: identity.ID,
},
{
}
if isFirstOrg {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't give support-admin to all orgs!

Comment on lines 180 to 182
if org == nil {
panic("missing org id in context")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these panics are programmer errors, and should be obvious from tests. If you remove them, it will still panic, but with a worse message.


if !roots.AppendCertsFromPEM([]byte(opts.CA)) {
logging.Warnf("failed to load TLS CA, invalid PEM")
if len(raw) == 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added some checks in this file to avoid panics I ran into.

Copy link
Contributor

@pdevine pdevine left a comment

Choose a reason for hiding this comment

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

Looks good. This will help quite a bit with RLS because the current org in the DB transaction will get set up the same way we're setting it here.

internal/access/signup.go Outdated Show resolved Hide resolved
run(t, setupDB(t, pgsql))
db := setupDB(t, pgsql)
run(t, db)
db.Rollback()
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. I just added db.Close() in my own changes here because there will be two connections in the RLS changes (the privileged and the unprivileged connection). Rollback seems better though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

afaict it shouldn't need to be closed.

internal/server/debug_test.go Show resolved Hide resolved
internal/server/middleware.go Outdated Show resolved Hide resolved
internal/server/models/organization.go Outdated Show resolved Hide resolved
get(a, noAuthn, "/api/settings", a.GetSettings)
put(a, authn, "/api/settings", a.UpdateSettings)
add(a, noAuthn, route[api.EmptyRequest, WellKnownJWKResponse]{
get(a, noAuthnWithOrg, "/api/providers/:id", a.GetProvider)
Copy link
Contributor

Choose a reason for hiding this comment

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

There's probably no way for someone to guess a provider ID, but would we want to also return fake data here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we might need to. Not entirely sure yet. provider IDs are somewhat guessable if you have an unlimited number of guesses. Also I think there might be problems with generating reliably-convincing fake data. especially since we're open source.

@@ -16,3 +23,15 @@ func (a *API) addRewrites() {
// addRedirects for API endpoints that have moved to a different path
func (a *API) addRedirects() {
}

func (a *API) deprecatedRoutes(noAuthnNoOrg *gin.RouterGroup) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels weird since there would be no way to add deprecated routes to other RouterGroups.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, you'd have to pass in the other router group as an argument. I could pass in the base router group and let you redefine your own middleware etc, but that felt weird too

@vercel vercel bot temporarily deployed to Preview August 16, 2022 17:54 Inactive
@vercel vercel bot temporarily deployed to Preview August 16, 2022 18:54 Inactive
Copy link
Collaborator

@BruceMacD BruceMacD left a comment

Choose a reason for hiding this comment

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

looks good 👍

@ssoroka ssoroka merged commit 449578d into main Aug 16, 2022
@ssoroka ssoroka deleted the host-fix branch August 16, 2022 20:11
@dnephin dnephin mentioned this pull request Aug 18, 2022
13 tasks
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.

None yet

3 participants