@@ -81,12 +81,13 @@ func (api *API) postToken(rw http.ResponseWriter, r *http.Request) {
81
81
}
82
82
83
83
cookie , 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 ,
90
91
})
91
92
if err != nil {
92
93
if database .IsUniqueViolation (err , database .UniqueIndexApiKeyName ) {
@@ -125,9 +126,10 @@ func (api *API) postAPIKey(rw http.ResponseWriter, r *http.Request) {
125
126
126
127
lifeTime := time .Hour * 24 * 7
127
128
cookie , _ , 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 ,
131
133
// All api generated keys will last 1 week. Browser login tokens have
132
134
// a shorter life.
133
135
ExpiresAt : database .Now ().Add (lifeTime ),
@@ -356,18 +358,6 @@ func (api *API) tokenConfig(rw http.ResponseWriter, r *http.Request) {
356
358
)
357
359
}
358
360
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
-
371
361
func (api * API ) validateAPIKeyLifetime (lifetime time.Duration ) error {
372
362
if lifetime <= 0 {
373
363
return xerrors .New ("lifetime must be positive number greater than 0" )
0 commit comments