mirror of
https://github.com/mudler/luet.git
synced 2025-06-20 04:34:37 +00:00
Contact the notary server if ```--verify``` is specified (or `verify: true` is enabled on the repo config) and verify if the image is signed, use the returned value to pull the verified image.
37 lines
764 B
Go
37 lines
764 B
Go
package imgworker
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/moby/buildkit/session"
|
|
"github.com/moby/buildkit/session/auth"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
func NewDockerAuthProvider(auth *types.AuthConfig) session.Attachable {
|
|
return &authProvider{
|
|
config: auth,
|
|
}
|
|
}
|
|
|
|
type authProvider struct {
|
|
config *types.AuthConfig
|
|
}
|
|
|
|
func (ap *authProvider) Register(server *grpc.Server) {
|
|
// no-op
|
|
}
|
|
|
|
func (ap *authProvider) Credentials(ctx context.Context, req *auth.CredentialsRequest) (*auth.CredentialsResponse, error) {
|
|
res := &auth.CredentialsResponse{}
|
|
if ap.config.IdentityToken != "" {
|
|
res.Secret = ap.config.IdentityToken
|
|
} else {
|
|
res.Username = ap.config.Username
|
|
res.Secret = ap.config.Password
|
|
}
|
|
return res, nil
|
|
}
|