api/graph: validate OAuth grants when submitting build

An OAuth grants string can be supplied when submitting a build
manifest. Validate it to make sure it's well-formed.
This commit is contained in:
Simon Ser 2023-10-04 14:20:21 +00:00 committed by Drew DeVault
parent 9910ba36f6
commit 12bb3fd8a9
1 changed files with 7 additions and 0 deletions

View File

@ -299,6 +299,13 @@ func (r *mutationResolver) Submit(ctx context.Context, manifest string, tags []s
return nil, secretsErr
}
if man.OAuth != "" {
_, err := auth.DecodeGrants(ctx, man.OAuth)
if err != nil {
return nil, err
}
}
var job model.Job
if err := database.WithTx(ctx, nil, func(tx *sql.Tx) error {
tags := strings.Join(tags, "/")