Registry of staff identities
Allows you to query staff identities using the idm api.
Please note: Querying staff entities requires a different idr just for entities.
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 staff identity registry
@idr = Soar::Registry::Staff::Identity.new(configuration)
Getting a list of identifiers
> identifiers = @idr.get_identifiers( {"email" => "[email protected]"} )
> identifiers = @idr.get_identifiers( {"identity_id" => "identity-820d5660-2204-4f7d-8c04-746313439b81"} )
> puts identifiers.inspect
["[email protected]", "identity-820d5660-2204-4f7d-8c04-746313439b81"]
Getting a list of roles
> roles = @idr.get_roles( {"email" => "[email protected]"} )
> roles = @idr.get_roles( {"identity_id" => "identity-820d5660-2204-4f7d-8c04-746313439b81"} )
> puts roles.inspect
["staff", "configuration_publisher", "configuration_consumer"]
Getting a hash of attributes for a role
> role = 'staff'
> attributes = @idr.get_attributes( {"email" => "[email protected]"}, role)
> attributes = @idr.get_attributes( {"identity_id" => "identity-820d5660-2204-4f7d-8c04-746313439b81"}, role )
> puts attributes.inspect
{
"staff": {
"department": "technical"
}
}
Getting a hash of all attributes
> attributes = @idr.get_attributes( {"email" => "[email protected]"} )
> attributes = @idr.get_attributes( {"identity_id" => "identity-820d5660-2204-4f7d-8c04-746313439b81"} )
> 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
Quicktest
$ 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
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;
Unit tests
Run dynamodb
$ docker-compose up
Open another terminal and run:
$ sudo -H pip install awscli
$ aws configure
$ bundle
$ rspec
Useful commands:
$ aws dynamodb list-tables --endpoint-url http://localhost:8000
$ aws dynamodb delete-table --table-name identities --endpoint-url http://localhost:8000