This change ensures that when there is a CredentialsShared or a CredentialsAdded event with a new Connection, that a ConnectionAdded event will be fired first.
This change also ensures that the connection_url can be derived from both the credential_issuer_url and the redirect_url in a similar fashion. This means that if a server is both a Credential Issuer as well as a Relying Party, then it's connection_url while in the Credential Issuer role will be equal to it's connection_url while in the Relying Party role.
This in turn enables us to use the issuer/client_name together with the connection_url to generate Connection IDs (instead of just based on the issuer/client_name which has severe security risks).
Abstracting the code for inserting and updating of Connections results in cleaner and less error-prone code:
let previously_connected = state.connections.contains(connection_url, &issuer_name);
let mut connections = state.connections;
let connection = connections.insert_or_update(connection_url, &issuer_name);
At a later stage we could implement something similar for History, e.g:
// History
if !history_credentials.is_empty() {
// Only add a `ConnectionAdded` event if the connection was not previously connected.
if !previously_connected {
state.history.push(HistoryEvent {
connection_name: connection.name.clone(),
event_type: EventType::ConnectionAdded,
connection_id: connection.id.clone(),
date: connection.last_interacted.clone(),
credentials: vec![],
});
}
state.history.push(HistoryEvent {
connection_name: connection.name.clone(),
event_type: EventType::CredentialsAdded,
connection_id: connection.id.clone(),
date: connection.last_interacted.clone(),
credentials: history_credentials,
});
}
would be converted to:
// History
if !history_credentials.is_empty() {
// Only add a `ConnectionAdded` event if the connection was not previously connected.
if !previously_connected {
state.history.append_connection_added_event(connection, vec![]);
}
state.history.append_credentials_added_event(connection, history_credentials);
}
Links to any relevant issues
fixes #125
How the change has been tested
Updated integration test to handle history and connections.
Added unit tests for the Connections struct.
Manual testing with both NGDIL and the SURF edubadges demo website
Definition of Done checklist
Add an x to the boxes that are relevant to your changes.
[x] I have followed the contribution guidelines for this project
[x] I have performed a self-review of my own code
[x] I have commented my code, particularly in hard-to-understand areas
[ ] I have made corresponding changes to the documentation
[x] I have added tests that prove my fix is effective or that my feature works
[x] New and existing unit tests pass locally with my changes
Description of change
This change ensures that when there is a
CredentialsShared
or aCredentialsAdded
event with a new Connection, that aConnectionAdded
event will be fired first.This change also ensures that the
connection_url
can be derived from both thecredential_issuer_url
and theredirect_url
in a similar fashion. This means that if a server is both a Credential Issuer as well as a Relying Party, then it'sconnection_url
while in the Credential Issuer role will be equal to it'sconnection_url
while in the Relying Party role.This in turn enables us to use the issuer/client_name together with the
connection_url
to generate Connection IDs (instead of just based on the issuer/client_name which has severe security risks).Abstracting the code for inserting and updating of Connections results in cleaner and less error-prone code:
At a later stage we could implement something similar for History, e.g:
would be converted to:
Links to any relevant issues
fixes #125
How the change has been tested
history
andconnections
.Connections
struct.Definition of Done checklist
Add an
x
to the boxes that are relevant to your changes.