configstore: generate User and Project secret

This commit is contained in:
Simone Gotti 2019-05-07 17:16:42 +02:00
parent 4154be3370
commit 2675aee333
3 changed files with 10 additions and 2 deletions

View File

@ -133,6 +133,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, project *types.Projec
project.ID = uuid.NewV4().String() project.ID = uuid.NewV4().String()
project.Parent.Type = types.ConfigTypeProjectGroup project.Parent.Type = types.ConfigTypeProjectGroup
project.Secret = util.EncodeSha1Hex(uuid.NewV4().String())
pcj, err := json.Marshal(project) pcj, err := json.Marshal(project)
if err != nil { if err != nil {

View File

@ -91,6 +91,7 @@ func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest)
user := &types.User{ user := &types.User{
ID: uuid.NewV4().String(), ID: uuid.NewV4().String(),
Name: req.UserName, Name: req.UserName,
Secret: util.EncodeSha1Hex(uuid.NewV4().String()),
} }
if req.CreateUserLARequest != nil { if req.CreateUserLARequest != nil {
if user.LinkedAccounts == nil { if user.LinkedAccounts == nil {

View File

@ -73,6 +73,9 @@ type User struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
// A secret string that could be used for signing or other purposes
Secret string `json:"secret,omitempty"`
LinkedAccounts map[string]*LinkedAccount `json:"linked_accounts,omitempty"` LinkedAccounts map[string]*LinkedAccount `json:"linked_accounts,omitempty"`
// Optional local auth // Optional local auth
@ -233,6 +236,9 @@ type Project struct {
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
// A secret string that could be used for signing or other purposes
Secret string `json:"secret,omitempty"`
Parent Parent `json:"parent,omitempty"` Parent Parent `json:"parent,omitempty"`
Visibility Visibility `json:"visibility,omitempty"` Visibility Visibility `json:"visibility,omitempty"`