Registry of staff identities

Allows you to find staff identities by id using Soar::Registry::Staff::Identity::Id or email Soar::Registry::Staff::Identity::Email

Quickstart

Required configuration

See config/config.yml

rule_set:
  adaptor: 'Soar::Registry::Staff::Translator::DynamoDb'
provider:
  adaptor: 'Soar::Registry::Staff::Directory::DynamoDb::Identity'
  config: 
    table: 'identities'
    region: 'us-west-2'
    endpoint: 'http://localhost:8000'
  credentials:
    username: 'username'
    password: 'secret'

Create an instance of the chosen staff identity registry

Find by id

require 'soar/registry/staff/identity/id'
@id_idr = Soar::Registry::Staff::Identity::Id.new(configuration)

Find by email

require 'soar/registry/staff/identity/email'
@email_idr = Soar::Registry::Staff::Identity::Email.new(configuration)

Getting a list of identifiers

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

Getting a list of roles

> roles = @id_idr.get_roles("identity-820d5660-2204-4f7d-8c04-746313439b81")
> roles = @email_idr.get_roles("[email protected]")
> puts roles.inspect
["staff", "configuration_publisher", "configuration_consumer"]

Getting a hash of attributes for a role

> role = 'staff'
> attributes = @id_idr.get_attributes("identity-820d5660-2204-4f7d-8c04-746313439b81", role)
> attributes = @email_idr.get_attributes("[email protected]", role)
> puts attributes.inspect
{
    "staff": {
        "department": "technical"
    }
}

Getting a hash of all attributes

> attributes = @id_idr.get_attributes("identity-820d5660-2204-4f7d-8c04-746313439b81")
> attributes = @email_idr.get_attributes("[email protected]")
> 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"
    }
}

Quicktest

Local Stub

TEST_ORCHESTRATION_PROVIDER=Stub rspec

DynamoDb

$ TEST_ORCHESTRATION_PROVIDER=DynamoDb docker-compose --file docker-compose.test.yml  up --abort-on-container-exit --remove-orphans 

CI

NB: container_name in docker-compose.ci.yml corresponds with name parameter of docker ps command in below bash script.

#!/bin/bash
TEST_ORCHESTRATION_PROVIDER=DynamoDb docker-compose --file docker-compose.test.yml up --build --abort-on-container-exit --remove-orphans --force-recreate;
EXIT_CODE=$(docker ps -a -f "name=soar-registry-staff" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
exit $EXIT_CODE;

Useful commands:

$ aws dynamodb list-tables --endpoint-url http://localhost:8000
$ aws dynamodb delete-table --table-name identities --endpoint-url http://localhost:8000

Resources

References