Commit d79a6207 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

feat: remove "-/" prefix from servercore revocation URLs

This gives the revocation endpoints URL like "revocation/{action}/{parameters}", which is consistent with the session endpoints that were recently changed to "session/{sessiontoken}/{action}".
parent ca06aa7f
...@@ -154,7 +154,7 @@ func (s *Server) Revoke(credid irma.CredentialTypeIdentifier, key string) error ...@@ -154,7 +154,7 @@ func (s *Server) Revoke(credid irma.CredentialTypeIdentifier, key string) error
} }
func ParsePath(path string) (token, noun string, arg []string, err error) { func ParsePath(path string) (token, noun string, arg []string, err error) {
rev := regexp.MustCompile("-/revocation/(records|latestrecords|issuancerecord)/?(.*)$") rev := regexp.MustCompile("revocation/(records|latestrecords|issuancerecord)/?(.*)$")
matches := rev.FindStringSubmatch(path) matches := rev.FindStringSubmatch(path)
if len(matches) == 3 { if len(matches) == 3 {
args := strings.Split(matches[2], "/") args := strings.Split(matches[2], "/")
......
...@@ -214,7 +214,7 @@ func (session *session) handlePostCommitments(commitments *irma.IssueCommitmentM ...@@ -214,7 +214,7 @@ func (session *session) handlePostCommitments(commitments *irma.IssueCommitmentM
return sigs, nil return sigs, nil
} }
// POST -/revocation/records // POST revocation/records
func (s *Server) handlePostRevocationRecords(records []*irma.RevocationRecord) (interface{}, *irma.RemoteError) { func (s *Server) handlePostRevocationRecords(records []*irma.RevocationRecord) (interface{}, *irma.RemoteError) {
if err := s.conf.IrmaConfiguration.RevocationStorage.AddRevocationRecords(records); err != nil { if err := s.conf.IrmaConfiguration.RevocationStorage.AddRevocationRecords(records); err != nil {
return nil, server.RemoteError(server.ErrorUnknown, err.Error()) // TODO error type return nil, server.RemoteError(server.ErrorUnknown, err.Error()) // TODO error type
...@@ -222,7 +222,7 @@ func (s *Server) handlePostRevocationRecords(records []*irma.RevocationRecord) ( ...@@ -222,7 +222,7 @@ func (s *Server) handlePostRevocationRecords(records []*irma.RevocationRecord) (
return nil, nil return nil, nil
} }
// GET -/revocation/records/{credtype}/{index} // GET revocation/records/{credtype}/{index}
func (s *Server) handleGetRevocationRecords( func (s *Server) handleGetRevocationRecords(
cred irma.CredentialTypeIdentifier, index uint64, cred irma.CredentialTypeIdentifier, index uint64,
) ([]*irma.RevocationRecord, *irma.RemoteError) { ) ([]*irma.RevocationRecord, *irma.RemoteError) {
...@@ -236,7 +236,7 @@ func (s *Server) handleGetRevocationRecords( ...@@ -236,7 +236,7 @@ func (s *Server) handleGetRevocationRecords(
return records, nil return records, nil
} }
// GET -/revocation/latestrecords/{credtype}/{count} // GET revocation/latestrecords/{credtype}/{count}
func (s *Server) handleGetLatestRevocationRecords( func (s *Server) handleGetLatestRevocationRecords(
cred irma.CredentialTypeIdentifier, count uint64, cred irma.CredentialTypeIdentifier, count uint64,
) ([]*irma.RevocationRecord, *irma.RemoteError) { ) ([]*irma.RevocationRecord, *irma.RemoteError) {
...@@ -250,7 +250,7 @@ func (s *Server) handleGetLatestRevocationRecords( ...@@ -250,7 +250,7 @@ func (s *Server) handleGetLatestRevocationRecords(
return records, nil return records, nil
} }
// POST -/revocation/issuancerecord/{credtype}/{keycounter} // POST revocation/issuancerecord/{credtype}/{keycounter}
func (s *Server) handlePostIssuanceRecord( func (s *Server) handlePostIssuanceRecord(
cred irma.CredentialTypeIdentifier, counter uint64, message []byte, cred irma.CredentialTypeIdentifier, counter uint64, message []byte,
) (string, *irma.RemoteError) { ) (string, *irma.RemoteError) {
......
...@@ -515,7 +515,7 @@ func (rs *RevocationStorage) getSettings(typ CredentialTypeIdentifier) *Revocati ...@@ -515,7 +515,7 @@ func (rs *RevocationStorage) getSettings(typ CredentialTypeIdentifier) *Revocati
func (RevocationClient) PostRevocationRecords(urls []string, records []*RevocationRecord) { func (RevocationClient) PostRevocationRecords(urls []string, records []*RevocationRecord) {
transport := NewHTTPTransport("") transport := NewHTTPTransport("")
for _, url := range urls { for _, url := range urls {
if err := transport.Post(url+"/-/revocation/records", nil, &records); err != nil { if err := transport.Post(url+"/revocation/records", nil, &records); err != nil {
Logger.Warn("error sending revocation update", err) Logger.Warn("error sending revocation update", err)
} }
} }
...@@ -523,7 +523,7 @@ func (RevocationClient) PostRevocationRecords(urls []string, records []*Revocati ...@@ -523,7 +523,7 @@ func (RevocationClient) PostRevocationRecords(urls []string, records []*Revocati
func (client RevocationClient) PostIssuanceRecord(typ CredentialTypeIdentifier, counter uint, message signed.Message, url string) error { func (client RevocationClient) PostIssuanceRecord(typ CredentialTypeIdentifier, counter uint, message signed.Message, url string) error {
return NewHTTPTransport(url).Post( return NewHTTPTransport(url).Post(
fmt.Sprintf("-/revocation/issuancerecord/%s/%d", typ, counter), nil, []byte(message), fmt.Sprintf("revocation/issuancerecord/%s/%d", typ, counter), nil, []byte(message),
) )
} }
...@@ -535,7 +535,7 @@ func (client RevocationClient) FetchRevocationRecords(typ CredentialTypeIdentifi ...@@ -535,7 +535,7 @@ func (client RevocationClient) FetchRevocationRecords(typ CredentialTypeIdentifi
transport := NewHTTPTransport("") transport := NewHTTPTransport("")
for _, url := range client.Conf.CredentialTypes[typ].RevocationServers { for _, url := range client.Conf.CredentialTypes[typ].RevocationServers {
transport.Server = url transport.Server = url
err = transport.Get(fmt.Sprintf("-/revocation/records/%s/%d", typ, index), &records) err = transport.Get(fmt.Sprintf("revocation/records/%s/%d", typ, index), &records)
if err == nil { if err == nil {
return records, nil return records, nil
} else { } else {
...@@ -551,7 +551,7 @@ func (client RevocationClient) FetchLatestRevocationRecords(typ CredentialTypeId ...@@ -551,7 +551,7 @@ func (client RevocationClient) FetchLatestRevocationRecords(typ CredentialTypeId
transport := NewHTTPTransport("") transport := NewHTTPTransport("")
for _, url := range client.Conf.CredentialTypes[typ].RevocationServers { for _, url := range client.Conf.CredentialTypes[typ].RevocationServers {
transport.Server = url transport.Server = url
err := transport.Get(fmt.Sprintf("-/revocation/latestrecords/%s/%d", typ, count), &records) err := transport.Get(fmt.Sprintf("revocation/latestrecords/%s/%d", typ, count), &records)
if err == nil { if err == nil {
return records, nil return records, nil
} else { } else {
......
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