Given a file of the following structure:
-
slack: U123456
jira: [email protected]
-
slack: U234567
jira: [email protected]
This service answers questions of the following form:
For one that calls themselves
[email protected]
onjira
, what is their username on Slack? (Answer:U123456
).
A set of usernames related to a person is called an identity.
Run:
cp .env.example .env
docker run --rm --interactive --tty -v $(pwd):/app composer:2.1 install
Note:
composer:2.1
pins the composer version according to this repo'scomposer.lock
packages.
To install vendor dependencies. Then, to boot the containers, use:
./vendor/bin/sail up
While keeping the containers up (booted by sail up
command), in the separate terminal window run:
./vendor/bin/sail artisan migrate
./vendor/bin/sail artisan db:seed
Note down the token given to you.
For convenience, you can setup a Bash Alias for the Sail command.
curl 'http://localhost/api/whose-name/[email protected]&s=jira&q=slack' \
-H "Accept: application/json" \
-H "Authorization: Bearer <YOURTOKEN>"
{"username":"U123456"}
Note: the Accept
header is important for all requests.
See the whose-name-client repository for a client of this API.
By default, the project uses the tests/whosename.yml
file. The file contains two users and is not suited for more extensive work or running a working copy of the API.
If you'd like to change the path, modify the following entry in your .env
file.
WHOSENAME_YAML=tests/whosename.yml
Because of Docker containers, the file must be located inside the repository.
For your convenience, the db:seed
command created a user for you with the following credentials:
email: [email protected]
password: test
If you need to create another user, use the user:create
Artisan command:
./vendor/bin/sail artisan user:create someuser [email protected]
The command will ask for a password for this user.
To request a token for a given user, you can use the /api/request-token
API endpoint:
curl -X POST 'http://localhost/api/request-token' \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"email":"[email protected]","password":"test","title":"test@my-laptop","abilities":["whose-name"]}'
Where:
email
andpassword
are valid user credentialstitle
is a required token title. It should describe, where the token will be used (e.g."test@my-laptop"
)abilities
is an array of abilities the token can access. For now, only thewhose-name
ability is available.
This repository follows the following conventions:
- Tests communicate purpose of the code
- Domain separation into domain logic, infrastructure and application code
- Framework is a client of the domain, not the owner
- Architecture Decision Ledger to communicate design decisions
To get to know what does the code do, run the test suite:
./vendor/bin/sail test --group usage,behavior
To see all tests, including edge case tests, run the complete test suite:
./vendor/bin/sail test
See:
- tests for more information on how to use the codebase
- domain/WhoseName for domain objects. Specifically look for the Identity class.
- infrastructure/WhoseName for a Yaml file persistence implementation
- routes/api.php for endpoint definitions
- docs/adl for design decisions
Laravel is a web application framework with expressive, elegant syntax, written in PHP.
Laravel has a thorough documentation and video tutorial library, making it a breeze to get started with the framework.
A deploy workflow has been set up on the main
branch for continuous deployment.
See .github/workflows/deploy.yml for more information.
The service is available under the whosename.makimo.pl address.
To manage users on production, you need access to access [email protected]
via SSH.
To add new users use the ./artisan user:create
command. See Creating users and requesting tokens section for more information.
To change or remove users, use ./artisan tinker
and play with App\Models\User
Eloquent Model, e.g.
$user = App\Models\User::where('email', '[email protected]')->find();
$user->delete();
The whose-name-data handles all data for this service. See it's README for more information.