Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding in seperate status base URI #660

Merged
merged 11 commits into from
Aug 23, 2023
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type ServicesConfig struct {
StorageProvider string `toml:"storage" conf:"default:bolt"`
StorageOptions []storage.Option `toml:"storage_option"`
ServiceEndpoint string `toml:"service_endpoint" conf:"default:http://localhost:8080"`
StatusEndpoint string `toml:"status_endpoint" conf:"default:http://localhost:8080"`
michaelneale marked this conversation as resolved.
Show resolved Hide resolved

// Application level encryption configuration. Defines how values are encrypted before they are stored in the
// configured KV store.
Expand Down
24 changes: 18 additions & 6 deletions config/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
// serviceInfo is intended to be a singleton object for static service info.
// WARNING: it is **NOT** currently thread safe.
type serviceInfo struct {
name string
description string
version string
apiBase string
apiVersion string
servicePaths map[framework.Type]string
name string
description string
version string
apiBase string
statusBaseUrl string

Check warning on line 33 in config/info.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: struct field statusBaseUrl should be statusBaseURL (revive)
michaelneale marked this conversation as resolved.
Show resolved Hide resolved
apiVersion string
servicePaths map[framework.Type]string
}

func Name() string {
Expand All @@ -57,6 +58,17 @@
return si.apiBase
}

func SetStatusBase(url string) {
if strings.LastIndexAny(url, "/") == len(url)-1 {
url = url[:len(url)-1]
}
si.statusBaseUrl = url
michaelneale marked this conversation as resolved.
Show resolved Hide resolved
}

func GetStatusBase() string {
return si.statusBaseUrl
michaelneale marked this conversation as resolved.
Show resolved Hide resolved
}

func SetServicePath(service framework.Type, path string) {
// normalize path
if strings.IndexAny(path, "/") == 0 {
Expand Down
1 change: 1 addition & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func NewSSIServer(shutdown chan os.Signal, cfg config.SSIServiceConfig) (*SSISer

// make sure to set the api base in our service info
config.SetAPIBase(cfg.Services.ServiceEndpoint)
config.SetStatusBase(cfg.Services.StatusEndpoint)

// service-level routers
engine.GET(HealthPrefix, router.Health)
Expand Down
10 changes: 8 additions & 2 deletions pkg/service/credential/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ func (s Service) createStatusListEntryForCredential(ctx context.Context, credID
}, nil
}

func getStatusURI(statusBase string, statusListID string) string {
if len(statusBase) > 0 {
return fmt.Sprintf("%s/status/%s", statusBase, statusListID)
michaelneale marked this conversation as resolved.
Show resolved Hide resolved
}
return fmt.Sprintf("%s/status/%s", config.GetServicePath(framework.Credential), statusListID)
}

func (s Service) createStatusListCredential(ctx context.Context, tx storage.Tx, statusPurpose statussdk.StatusPurpose, issuerID, fullyQualifiedVerificationMethodID string, slcMetadata StatusListCredentialMetadata) (int, *credential.VerifiableCredential, error) {
statusListID := uuid.NewString()
statusListURI := fmt.Sprintf("%s/status/%s", config.GetServicePath(framework.Credential), statusListID)

statusListURI := getStatusURI(config.GetStatusBase(), statusListID)
generatedStatusListCredential, err := statussdk.GenerateStatusList2021Credential(statusListURI, issuerID, statusPurpose, []credential.VerifiableCredential{})
if err != nil {
return -1, nil, sdkutil.LoggingErrorMsg(err, "could not generate status list")
Expand Down
Loading