smart-id-rust-client 0.2.0

Smart ID Rust Client
Documentation

Introduction

The library can be used for easy integration with the Smart-ID API. It provides a simple interface for mobile authentication and mobile digital signing using Smart-ID. Additional utilities has been provided for easy integration with the Smart-ID API:

  • generate digest and calculate verification code
  • helper structs
  • interactions with the mobile end-user

Status

Supporting SmartID using:

  • Nation Registry number
  • QR code

Documentation

Smart-ID Documentation

Demo Environment

Demo Parameters

Build

cargo build

Examples

# with debug logs (default)
cargo run --example smart_id_client

# only with info logs
RUST_LOG=info cargo run --example smart_id_client

Tests

cargo test

Manual Tests

To fully test the libraries interactions with the Smart-ID API, you will need to run the tests in app_interaction_tests.rs. These tests require a Qualified Smart-ID account and a mobile device with the Smart-ID app installed.

Documentation

cargo doc --no-deps --open

Example Client

See the examples folder for a simple example client. To create an SmartID account, download the app: SmartID App

The example application goes through the following use cases:

  • Verify Certificate Existence
  • SmartID Authentication
  • SmartID Digital Signature

The example is using a MOCK ID to simulate the SmartID user.

cargo run --example smart_id_client

Configuration

Default values are provided and targets the TEST environment of Smart ID. The required environment variables are:

ENV_VAR DESCRIPTION REQUIRED
HOST_URL The host address of the Smart ID Service Y
RELYING_PARTY_UUID The UUID assigned to the Relying-party - provided by Smart ID Y
RELYING_PARTY_NAME The unique name assigned to the Relying-Party - provided by Smart ID Y
CLIENT_REQ_NETWORK_TIMEOUT_MILLIS The timeout for the REST client when requesting Smart ID Services N - default ()
CLIENT_REQ_MAX_ATTEMPTS The maximum attempts for the REST client retry mechanism
CLIENT_REQ_DELAY_SECONDS_BETWEEN_ATTEMPTS The wait time between consecutive REST client requests
ENABLE_POLLING_BY_LIB Enable automatic polling (when false - polling MUST be implemented by callee

SmartID configuration can be loaded form environment variables:

/// Get default Config (from environment variables)
let cfg = get_config_from_env();

Or set manually

/// Create SmartID Config
let cfg = SmartIDConfig {
    root_url: "https://sid.demo.sk.ee".to_string(),
    api_path: "/smart-id-rp/v3".to_string(),
    relying_party_uuid: "test-uuid".to_string(),
    relying_party_name: "test-name".to_string(),
    client_request_timeout: Some(30000),
}

Examples

Examples of the various flows with explanations can be found in smart_id_client.rs. You will need to update the RELYING_PARTY environment variables in config.toml for these to work.

Examples of more complex auth->certificate->sign flows with instructions can be found in app_interaction_tests.rs. You will need to update the RELYING_PARTY variables in the test file for these to work.