Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

add sys admin screen for creating realms #426

Merged
merged 4 commits into from
Sep 1, 2020

Conversation

mikehelmick
Copy link
Contributor

Proposed Changes

  • System admins can create new realms (very basic)
  • clear user from cache when realms change - otherwise you can't select the new realm until record expires.

Release Note

System admin page to create realms from the UI instead of command line tools.

@googlebot googlebot added the cla: yes Auto: added by CLA bot when all committers have signed a CLA. label Aug 31, 2020
cmd/server/assets/admin/new.html Outdated Show resolved Hide resolved
<div class="invalid-feedback">
{{joinStrings ($realm.ErrorsFor "name") ", "}}
</div>
{{end}}
Copy link
Member

Choose a reason for hiding this comment

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

Should we add the help text beneath?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the isn't help text for name, but I added the region code one.

cmd/server/assets/admin/new.html Outdated Show resolved Hide resolved
cmd/server/assets/admin/new.html Outdated Show resolved Hide resolved
<div class="invalid-feedback">
{{joinStrings ($realm.ErrorsFor "UseRealmCertificateKey") ", "}}
</div>
{{end}}
Copy link
Member

Choose a reason for hiding this comment

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

Definitely want help text for this one

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 - hard help text to write.

cmd/server/assets/admin/realms.html Outdated Show resolved Hide resolved
cmd/server/assets/admin/realms.html Outdated Show resolved Hide resolved
cmd/server/assets/header.html Outdated Show resolved Hide resolved
pkg/controller/admin/admin.go Outdated Show resolved Hide resolved
@@ -35,6 +35,11 @@ type User struct {
AdminRealms []*Realm `gorm:"many2many:admin_realms"`
}

// CacheKey returns the key for this user in the distributed cache.
func (u *User) CacheKey() string {
return fmt.Sprintf("users:by_email:%s", u.Email)
Copy link
Member

Choose a reason for hiding this comment

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

hmm... we cache users by id and email (I think)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where this matters is in middleware/auth.go - line 77ish.
there it is cached by email

it's also interesting that the callback doesn't hit this

Copy link
Member

Choose a reason for hiding this comment

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

Oh hmmm... it does? Were you seeing something else? Which user query were you running?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the callbacks work - don't know what I Was doing wrong before

Copy link
Member

@sethvargo sethvargo left a comment

Choose a reason for hiding this comment

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

/lgtm

There's a debug printf left, but we can clean that up later

@@ -101,6 +104,7 @@ func (c *Controller) HandleCreateRealm() http.Handler {

func (c *Controller) renderNew(ctx context.Context, w http.ResponseWriter, realm *database.Realm) {
m := controller.TemplateMapFromContext(ctx)
fmt.Printf("errors %+v", realm.Errors())
Copy link
Member

Choose a reason for hiding this comment

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

Debug

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mikehelmick, sethvargo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [mikehelmick,sethvargo]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit 05b107a into google:main Sep 1, 2020
@google google locked and limited conversation to collaborators Oct 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Auto: added by CLA bot when all committers have signed a CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants