Registry of identities

Documentation

rubydoc.info

Quickstart

Example data

identities = [{
    "uuid": "62936e70-1815-439b-bf89-8492855a7e6b",
    "email": "[email protected]",
}]

Directory

Create a directory provider

> require 'soar/registry/directory'
> directory_provider = Soar::Registry::Directory::Provider::Stub.new(
    table: "identities",
    index: ["uuid", "email"]
)

Create a directory

> directory = Soar::Registry::Directory.new(directory_provider)

Instantiation

Manual instantiation

Staff Email IDR

Search for identifiers by email address. Used by soar-authentication-identity_uuid_translator to translate an authenticated identifier to an UUID.

require 'soar/registry/identity'
identity_provider = Soar::Registry::Identity::Provider::Staff::Email.new({
    directory: directory,
    fetch_index: 'uuid',
    search_index: 'email'
})
@email_idr = Soar::Registry::Identity.new(identity_provider)

Factory instantiation

Create a selector

> require 'object_selector'
> selector = ObjectSelector.new(
  ObjectSelector::Provider::RegexRuleList.new({
    rules: [
      {
        regex: /\A[\w+\-.][email protected]\z/i,
        object: Soar::Registry::Identity::Provider::Staff::Email.new({
          directory: Object.new,
          fetch_index: SecureRandom.hex,
          search_index: SecureRandom.hex
        })
      },
      {
        regex: /\A[\w+\-.]+@.+/i,
        object: Soar::Registry::Identity::Provider::Customer::Email.new({
          directory: Object.new,
          fetch_index: SecureRandom.hex,
          search_index: SecureRandom.hex
        })
      },
      {
        regex: /\A[CF]{0,1}\d+\z/,
        object: Soar::Registry::Identity::Provider::Customer::ClientNumber.new({
          directory: Object.new,
          fetch_index: SecureRandom.hex,
          search_index: SecureRandom.hex
        })
      }
    ]
  })
)

Get an IDR

> selector_value = 'your-string-here'
idr = Soar::Registry::Identity::Factory.create({
  value: selector_value,
  selector: selector
})

Use your IDR

Getting a list of identifiers

> identifiers = @email_idr.get_identifiers("[email protected]") 
> puts identifiers.inspect
["[email protected]", "identity-820d5660-2204-4f7d-8c04-746313439b81"]

Getting a list of roles

> roles = @uuid_idr.get_roles("identity-820d5660-2204-4f7d-8c04-746313439b81")
> # get_roles is not applicable to staff email idr
> puts roles.inspect
["staff", "configuration_publisher", "configuration_consumer"]

Getting a hash of attributes for a role

> role = 'staff'
> attributes = @uuid_idr.get_attributes("identity-820d5660-2204-4f7d-8c04-746313439b81", role)
> # get_attributes is not applicable to staff email idr
> puts attributes.inspect
{
    "staff": {
        "department": "technical"
    }
}

Getting a hash of all attributes

> attributes = @uuid_idr.get_attributes("identity-820d5660-2204-4f7d-8c04-746313439b81")
> # get_attributes is not applicate to staff email idr
> puts attributes.inspect
{
    "identity_id" => "identity-820d5660-2204-4f7d-8c04-746313439b81",
    "entity_id"=> "entity-bad85eb9-0713-4da7-8d36-07a8e4b00eab",
    "email"=> "[email protected]",
    "roles"=> {
        "staff"=> {},
        "configuration_publisher"=> {
            "configuration_identifiers"=> ["*"]
        },
        "configuration_consumer"=> {
            "configuration_identifiers"=> ["*"]
        }
    },
    "address"=> {
        "detail"=> "Belvedere Office Park, Unit F",
        "street"=> "Bella Rosa Street",
        "suburb"=> "Tygervalley",
        "city"=> "Durbanville",
        "postal"=> "7550"
    }
}

Tests

Local

Start container dependencies

$ docker-compose up --build --remove-orphans --force-recreate

Soar::Registry::Identity::Provider::Customer::Uuid

$ CUSTOMER_DIRECTORY_CONFIG_FILE=config.mysql.yml ROLES_DIRECTORY_CONFIG_FILE=config.dynamo_db.yml TEST_ORCHESTRATION_PROVIDER=Customer::Uuid bundle exec cucumber --tags ~@future

Soar::Registry::Identity::Provider::Staff::Uuid

$ STAFF_DIRECTORY_CONFIG_FILE=config.ldap.yml ROLES_DIRECTORY_CONFIG_FILE=config.dynamo_db.yml TEST_ORCHESTRATION_PROVIDER=Staff::Uuid bundle exec cucumber 

Soar::Registry::Identity::Provider::Stub::Uuid

$ TEST_ORCHESTRATION_PROVIDER=Stub::Uuid bundle exec cucumber

Soar::Registry::Identity::Provider::Staff::Email

$ bundle exec rspec spec/staff/email_spec.rb

Soar::Registry::Identity::Provider::Customer::Email

$ bundle exec rspec spec/customer/email_spec.rb

Soar::Registry::Identity::Provider::Customer::ClientNumber

$ bundle exec rspec spec/customer/client_number_spec.rb

Soar::Registry::Identity::Factory

$ bundle exec rspec spec/authenticated_identity_factory_spec.rb spec/identity_uuid_factory_spec.rb

CI

Soar::Registry::Identity::Provider::Stub::Uuid

docker-compose --file docker-compose.ci.stub-uuid.yml --project-name soar-registry-identity-provider-stub-uuid up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistryidentityproviderstubuuid_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
docker-compose --file docker-compose.ci.staff-email.yml --project-name soar-registry-identity-provider-stub-uuid down --rmi local
exit $EXIT_CODE;

Soar::Registry::Identity::Provider::Staff::Email

docker-compose --file docker-compose.ci.staff-email.yml --project-name soar-registry-identity-provider-staff-email up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistryidentityproviderstaffemail_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
docker-compose --file docker-compose.ci.staff-email.yml --project-name soar-registry-identity-provider-staff-email down --rmi local
exit $EXIT_CODE;

Soar::Registry::Identity::Provider::Customer::Email

docker-compose --file docker-compose.ci.customer-email.yml --project-name soar-registry-identity-provider-customer-email up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistryidentityprovidercustomeremail_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
docker-compose --file docker-compose.ci.customer-email.yml --project-name soar-registry-identity-provider-customer-email down --rmi local
exit $EXIT_CODE;

Soar::Registry::Identity::Provider::Customer::ClientNumber

docker-compose --file docker-compose.ci.customer-client_number.yml --project-name soar-registry-identity-provider-customer-client_number up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistryidentityprovidercustomerclientnumber_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
docker-compose --file docker-compose.ci.customer-client_number.yml --project-name soar-registry-identity-provider-customer-client_number down --rmi local
exit $EXIT_CODE;

Soar::Registry::Identity::Factory

docker-compose --file docker-compose.ci.factory.yml --project-name soar-registry-identity-factory up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistryidentityfactory_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
docker-compose --file docker-compose.ci.factory.yml --project-name soar-registry-identity-factory down --rmi local
exit $EXIT_CODE;

Soar::Registry::Identity::Provider::Staff::Uuid

docker-compose --file docker-compose.ci.staff-uuid.yml --project-name soar-registry-identity-provider-staff-uuid up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistryidentityproviderstaffuuid_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
docker-compose --file docker-compose.ci.staff-uuid.yml --project-name soar-registry-identity-provider-staff-uuid down --rmi local
exit $EXIT_CODE;

Soar::Registry::Identity::Provider::Customer::Uuid

docker-compose --file docker-compose.ci.customer-uuid.yml --project-name soar-registry-identity-provider-customer-uuid up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistryidentityprovidercustomeruuid_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
docker-compose --file docker-compose.ci.customer-uuid.yml --project-name soar-registry-identity-provider-customer-uuid down --rmi local
exit $EXIT_CODE;

Resources

References