mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-24 08:15:52 +00:00
force update if the selfhosted process ends midway
This commit is contained in:
@@ -22,7 +22,7 @@ type OIDCIdPDiscoveryContents interface {
|
||||
|
||||
type OIDCIdPDiscovery interface {
|
||||
CreateStorage(ctx context.Context) error
|
||||
Upload(ctx context.Context, o OIDCIdPDiscoveryContents) error
|
||||
Upload(ctx context.Context, o OIDCIdPDiscoveryContents, forceUpdate bool) error
|
||||
Delete(ctx context.Context, o OIDCIdPDiscoveryContents) error
|
||||
}
|
||||
|
||||
|
||||
@@ -32,30 +32,32 @@ func (s *S3IdPDiscovery) CreateStorage(ctx context.Context) error {
|
||||
|
||||
// Upload uploads the OIDC provider's discovery configuration and JSON Web Key Set (JWKS) to the specified AWS S3 bucket.
|
||||
// This method is responsible for uploading the necessary OIDC configuration files to S3, making them accessible for OIDC clients.
|
||||
func (s *S3IdPDiscovery) Upload(ctx context.Context, o selfhosted.OIDCIdPDiscoveryContents) error {
|
||||
func (s *S3IdPDiscovery) Upload(ctx context.Context, o selfhosted.OIDCIdPDiscoveryContents, forceUpdate bool) error {
|
||||
discovery, err := o.Discovery()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
err = s.s3Client.CreateObjectPublic(ctx,
|
||||
CONFIGURATION_PATH,
|
||||
discovery,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to upload discovery document, %w", err)
|
||||
}
|
||||
|
||||
// Uplaod JWK
|
||||
jwk, err := o.JWK()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
err = s.s3Client.CreateObjectPublic(ctx,
|
||||
o.JWKsFileName(),
|
||||
jwk,
|
||||
)
|
||||
inputs := []client.ObjectInput{
|
||||
{
|
||||
Key: CONFIGURATION_PATH,
|
||||
Body: discovery,
|
||||
},
|
||||
{
|
||||
Key: o.JWKsFileName(),
|
||||
Body: jwk,
|
||||
},
|
||||
}
|
||||
if forceUpdate {
|
||||
err = s.s3Client.PutObjectsPublic(ctx, inputs)
|
||||
} else {
|
||||
err = s.s3Client.CreateObjectsPublic(ctx, inputs)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to upload JWK, %w", err)
|
||||
return fmt.Errorf("unable to upload object, %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package selfhosted
|
||||
|
||||
import "context"
|
||||
|
||||
func Execute(ctx context.Context, factory OIDCIdPFactory) error {
|
||||
func Execute(ctx context.Context, factory OIDCIdPFactory, forceUpdate bool) error {
|
||||
issuerMeta := factory.IssuerMeta()
|
||||
discovery := factory.IdPDiscovery()
|
||||
discoveryContents := factory.IdPDiscoveryContents(issuerMeta)
|
||||
@@ -14,7 +14,7 @@ func Execute(ctx context.Context, factory OIDCIdPFactory) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = discovery.Upload(ctx, discoveryContents)
|
||||
err = discovery.Upload(ctx, discoveryContents, forceUpdate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user