Fix generated Run component identity
This commit is contained in:
@@ -138,7 +138,7 @@ func ApplyPackageConfig(base Config, pkg PackageConfig) Config {
|
||||
base.ServerInstanceID = pkg.ServerInstanceID
|
||||
base.PluginID = pkg.PluginID
|
||||
base.ComponentKind = pkg.Kind
|
||||
base.ComponentKey = pkg.ProfileKey
|
||||
base.ComponentKey = packageComponentKey(pkg)
|
||||
base.KeyGeneration = pkg.KeyGeneration
|
||||
base.SecretRef = pkg.SecretRef
|
||||
if pkg.RunEndpointID != "" {
|
||||
@@ -184,7 +184,7 @@ func AuthenticatePackageGeneration(pkg PackageConfig, auth ComponentAuthResult)
|
||||
if err := ValidatePackageConfig(pkg); err != nil {
|
||||
return err
|
||||
}
|
||||
if auth.ServerInstanceID != pkg.ServerInstanceID || auth.Kind != pkg.Kind || auth.ProfileKey != pkg.ProfileKey {
|
||||
if auth.ServerInstanceID != pkg.ServerInstanceID || auth.Kind != pkg.Kind || auth.ProfileKey != packageComponentKey(pkg) {
|
||||
return fmt.Errorf("component authentication scope does not match package")
|
||||
}
|
||||
if !auth.Allowed {
|
||||
@@ -196,6 +196,13 @@ func AuthenticatePackageGeneration(pkg PackageConfig, auth ComponentAuthResult)
|
||||
return nil
|
||||
}
|
||||
|
||||
func packageComponentKey(pkg PackageConfig) string {
|
||||
if pkg.Kind == PackageComponentRun {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(pkg.ProfileKey)
|
||||
}
|
||||
|
||||
func fingerprint(value string) string {
|
||||
sum := sha256.Sum256([]byte(value))
|
||||
return hex.EncodeToString(sum[:])[:12]
|
||||
|
||||
Reference in New Issue
Block a user