Commit 45bbc9e5 authored by Sietse Ringers's avatar Sietse Ringers

feat: don't require revocation server URLs to end with /

parent 28d1babc
......@@ -539,7 +539,7 @@ func TestRevocationAll(t *testing.T) {
// check /update endpoint
url = revocationConfiguration.IrmaConfiguration.CredentialTypes[revocationTestCred].RevocationServers[0] +
"revocation/update/irma-demo.MijnOverheid.root/16"
"/revocation/update/irma-demo.MijnOverheid.root/16"
req, err = http.NewRequest(http.MethodGet, url, nil)
require.NoError(t, err)
res, err = (&http.Client{}).Do(req)
......
......@@ -67,8 +67,8 @@ func StartIrmaServer(t *testing.T, updatedIrmaConf bool) {
DisableSchemesUpdate: true,
SchemesPath: filepath.Join(testdata, irmaconf),
RevocationSettings: irma.RevocationSettings{
revocationTestCred: {RevocationServerURL: "http://localhost:48683/", SSE: true},
revKeyshareTestCred: {RevocationServerURL: "http://localhost:48683/"},
revocationTestCred: {RevocationServerURL: "http://localhost:48683", SSE: true},
revKeyshareTestCred: {RevocationServerURL: "http://localhost:48683"},
},
}
irmaServer, err = irmaserver.New(irmaServerConfiguration)
......@@ -96,8 +96,8 @@ var IrmaServerConfiguration = &requestorserver.Configuration{
SchemesPath: filepath.Join(testdata, "irma_configuration"),
IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
RevocationSettings: irma.RevocationSettings{
revocationTestCred: {RevocationServerURL: "http://localhost:48683/"},
revKeyshareTestCred: {RevocationServerURL: "http://localhost:48683/"},
revocationTestCred: {RevocationServerURL: "http://localhost:48683"},
revKeyshareTestCred: {RevocationServerURL: "http://localhost:48683"},
},
},
DisableRequestorAuthentication: true,
......@@ -112,8 +112,8 @@ var JwtServerConfiguration = &requestorserver.Configuration{
SchemesPath: filepath.Join(testdata, "irma_configuration"),
IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
RevocationSettings: irma.RevocationSettings{
revocationTestCred: {RevocationServerURL: "http://localhost:48683/"},
revKeyshareTestCred: {RevocationServerURL: "http://localhost:48683/"},
revocationTestCred: {RevocationServerURL: "http://localhost:48683"},
revKeyshareTestCred: {RevocationServerURL: "http://localhost:48683"},
},
JwtPrivateKeyFile: filepath.Join(testdata, "jwtkeys", "sk.pem"),
StaticSessions: map[string]interface{}{
......
......@@ -627,6 +627,11 @@ func (conf *Configuration) parseCredentialsFolder(manager *SchemeManager, issuer
if cred.RevocationUpdateSpeed == 0 {
cred.RevocationUpdateSpeed = RevocationParameters.ClientDefaultUpdateSpeed
}
for i, url := range cred.RevocationServers {
if url[len(url)-1] == '/' {
cred.RevocationServers[i] = url[:len(url)-1]
}
}
cred.Valid = conf.SchemeManagers[cred.SchemeManagerIdentifier()].Valid
credid := cred.Identifier()
conf.CredentialTypes[credid] = cred
......
......@@ -717,7 +717,7 @@ func (rs *RevocationStorage) Load(debug bool, dbtype, connstr string, settings R
rs.events = make(chan *sseclient.Event)
go rs.receiveUpdates()
}
url := fmt.Sprintf("%srevocation/updateevents/%s", urls[0], id.String())
url := fmt.Sprintf("%s/revocation/updateevents/%s", urls[0], id.String())
go rs.listenUpdates(id, url)
}
}
......@@ -837,7 +837,7 @@ func (client RevocationClient) PostIssuanceRecord(id CredentialTypeIdentifier, s
return err
}
return client.transport().Post(
fmt.Sprintf("%srevocation/issuancerecord/%s/%d", url, id, sk.Counter), nil, []byte(message),
fmt.Sprintf("%s/revocation/issuancerecord/%s/%d", url, id, sk.Counter), nil, []byte(message),
)
}
......@@ -868,7 +868,7 @@ func (client RevocationClient) FetchUpdateFrom(id CredentialTypeIdentifier, pkco
events := &revocation.EventList{ComputeProduct: true}
if e := client.getMultiple(
client.Conf.CredentialTypes[id].RevocationServers,
fmt.Sprintf("revocation/events/%s/%d/%d/%d", id, pkcounter, i[0], i[1]),
fmt.Sprintf("/revocation/events/%s/%d/%d/%d", id, pkcounter, i[0], i[1]),
events,
); e != nil {
err = e
......@@ -909,7 +909,7 @@ func (client RevocationClient) FetchUpdateLatest(id CredentialTypeIdentifier, pk
update := &revocation.Update{}
return update, client.getMultiple(
urls,
fmt.Sprintf("revocation/update/%s/%d/%d", id, count, pkcounter),
fmt.Sprintf("/revocation/update/%s/%d/%d", id, count, pkcounter),
&update,
)
}
......@@ -922,7 +922,7 @@ func (client RevocationClient) FetchUpdatesLatest(id CredentialTypeIdentifier, c
update := map[uint]*revocation.Update{}
return update, client.getMultiple(
urls,
fmt.Sprintf("revocation/update/%s/%d", id, count),
fmt.Sprintf("/revocation/update/%s/%d", id, count),
&update,
)
}
......
......@@ -337,6 +337,12 @@ func (conf *Configuration) verifyRevocation() error {
return errors.Errorf(message, credid)
}
}
if settings != nil && settings.RevocationServerURL != "" {
url := settings.RevocationServerURL
if url[len(url)-1] == '/' {
settings.RevocationServerURL = url[:len(url)-1]
}
}
}
return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment