Fix missing metaData in archive; Add iat to JWTs

This commit is contained in:
Lou Knauer 2022-03-10 14:09:13 +01:00
parent a9f6da7595
commit a448868f9c
2 changed files with 10 additions and 4 deletions

View File

@ -386,6 +386,12 @@ func (api *RestApi) stopJob(rw http.ResponseWriter, r *http.Request) {
go func() {
defer api.OngoingArchivings.Done()
if _, err := api.JobRepository.FetchMetadata(job); err != nil {
log.Errorf("archiving job (dbid: %d) failed: %s", job.ID, err.Error())
api.JobRepository.UpdateMonitoringStatus(job.ID, schema.MonitoringStatusArchivingFailed)
return
}
// metricdata.ArchiveJob will fetch all the data from a MetricDataRepository and create meta.json/data.json files
jobMeta, err := metricdata.ArchiveJob(job, context.Background())
if err != nil {

View File

@ -375,17 +375,17 @@ func (auth *Authentication) ProvideJWT(user *User) (string, error) {
return "", errors.New("environment variable 'JWT_PRIVATE_KEY' not set")
}
now := time.Now()
claims := jwt.MapClaims{
"sub": user.Username,
"roles": user.Roles,
"iat": now.Unix(),
}
if auth.JwtMaxAge != 0 {
claims["exp"] = time.Now().Add(auth.JwtMaxAge).Unix()
claims["exp"] = now.Add(auth.JwtMaxAge).Unix()
}
tok := jwt.NewWithClaims(jwt.SigningMethodEdDSA, claims)
return tok.SignedString(auth.jwtPrivateKey)
return jwt.NewWithClaims(jwt.SigningMethodEdDSA, claims).SignedString(auth.jwtPrivateKey)
}
func GetUser(ctx context.Context) *User {