@@ -81,12 +81,13 @@ func (api *API) postToken(rw http.ResponseWriter, r *http.Request) {
8181}
8282
8383cookie ,key ,err := api .createAPIKey (ctx , apikey.CreateParams {
84- UserID :user .ID ,
85- LoginType :database .LoginTypeToken ,
86- ExpiresAt :database .Now ().Add (lifeTime ),
87- Scope :scope ,
88- LifetimeSeconds :int64 (lifeTime .Seconds ()),
89- TokenName :tokenName ,
84+ UserID :user .ID ,
85+ LoginType :database .LoginTypeToken ,
86+ DeploymentValues :api .DeploymentValues ,
87+ ExpiresAt :database .Now ().Add (lifeTime ),
88+ Scope :scope ,
89+ LifetimeSeconds :int64 (lifeTime .Seconds ()),
90+ TokenName :tokenName ,
9091})
9192if err != nil {
9293if database .IsUniqueViolation (err ,database .UniqueIndexApiKeyName ) {
@@ -125,9 +126,10 @@ func (api *API) postAPIKey(rw http.ResponseWriter, r *http.Request) {
125126
126127lifeTime := time .Hour * 24 * 7
127128cookie ,_ ,err := api .createAPIKey (ctx , apikey.CreateParams {
128- UserID :user .ID ,
129- LoginType :database .LoginTypePassword ,
130- RemoteAddr :r .RemoteAddr ,
129+ UserID :user .ID ,
130+ DeploymentValues :api .DeploymentValues ,
131+ LoginType :database .LoginTypePassword ,
132+ RemoteAddr :r .RemoteAddr ,
131133// All api generated keys will last 1 week. Browser login tokens have
132134// a shorter life.
133135ExpiresAt :database .Now ().Add (lifeTime ),
@@ -356,18 +358,6 @@ func (api *API) tokenConfig(rw http.ResponseWriter, r *http.Request) {
356358)
357359}
358360
359- type createAPIKeyParams struct {
360- UserID uuid.UUID
361- RemoteAddr string
362- LoginType database.LoginType
363-
364- // Optional.
365- ExpiresAt time.Time
366- LifetimeSeconds int64
367- Scope database.APIKeyScope
368- TokenName string
369- }
370-
371361func (api * API )validateAPIKeyLifetime (lifetime time.Duration )error {
372362if lifetime <= 0 {
373363return xerrors .New ("lifetime must be positive number greater than 0" )