Staff roles (viewer, operator, billing) and the console's Audit view
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f8fcecd640
commit
b60cf45adf
19 files changed
+352
-24
No files matched your search
+38
-1
@@ -37,7 +37,8 @@ func newUsersCmd() *cobra.Command {
|
||||
newUserCreateCmd(open), newUserResetPasswordCmd(open),
|
||||
newUserJoinCmd(open), newUserLeaveCmd(open), newUserDeleteCmd(open),
|
||||
newUserAdminCmd(open, "promote", true, "Let an account see the cluster dashboard at /admin"),
|
||||
newUserAdminCmd(open, "demote", false, "Take away access to the cluster dashboard"))
|
||||
newUserAdminCmd(open, "demote", false, "Take away access to the cluster dashboard"),
|
||||
newUserRoleCmd(open))
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -177,6 +178,42 @@ func newUserStateCmd(open userOpener, verb string, state store.UserState, short
|
||||
}
|
||||
}
|
||||
|
||||
func newUserRoleCmd(open userOpener) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "role <user> <viewer|operator|billing|admin|none>",
|
||||
Short: "Give an account a part in running the gateway, from the pages under /admin",
|
||||
Long: "viewer looks at every administration page and changes nothing. operator\n" +
|
||||
"also runs the cluster from them: models through the mirror, a node's\n" +
|
||||
"engines. billing sees usage and quotas. admin may do anything. none takes\n" +
|
||||
"the role away. Every change made from those pages is in `llmgw ctl audit`.",
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
role := args[1]
|
||||
if role == "none" {
|
||||
role = ""
|
||||
}
|
||||
s, err := open(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer s.Close()
|
||||
u, err := resolveUser(cmd.Context(), s, args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.SetStaffRole(cmd.Context(), u.ID, role); err != nil {
|
||||
return err
|
||||
}
|
||||
if role == "" {
|
||||
fmt.Fprintf(cmd.OutOrStdout(), "%s has no part in running the gateway now\n", u.Email)
|
||||
} else {
|
||||
fmt.Fprintf(cmd.OutOrStdout(), "%s is now %s\n", u.Email, role)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newUserAdminCmd(open userOpener, verb string, admin bool, short string) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: verb + " <user>",
|
||||
|
||||
Reference in new issue
Block a user