2015-11-09 07:47:55 +05:30
# Running Examples
2015-08-18 05:57:27 +05:30
2015-11-09 07:47:55 +05:30
The quickest way to start experimenting with dex is to run a single dex-worker locally, with an in-process database, and then interact with it using the example programs in this directory.
2015-08-18 05:57:27 +05:30
## Build Everything and Start dex-worker
2015-11-09 07:47:55 +05:30
First, build the example webapp client and example CLI client.
2015-11-07 01:44:44 +05:30
```console
2015-11-09 07:47:55 +05:30
./build
```
Now copy the example configurations into place to get dex configured.
You can customize these later but the defaults should work fine.
2015-11-07 01:44:44 +05:30
```console
2016-05-19 06:48:20 +05:30
cp static/fixtures/clients.json.sample static/fixtures/clients.json
2015-11-09 07:47:55 +05:30
cp static/fixtures/connectors.json.sample static/fixtures/connectors.json
cp static/fixtures/users.json.sample static/fixtures/users.json
cp static/fixtures/emailer.json.sample static/fixtures/emailer.json
```
With `dex-worker` configuration in place we can start dex in local mode.
2015-11-07 01:44:44 +05:30
```console
2015-11-09 07:47:55 +05:30
./bin/dex-worker --no-db &
```
## Example Webapp Client
2016-05-19 06:48:20 +05:30
Build and run the example app webserver by pointing the discovery URL to local Dex, and
2015-08-18 05:57:27 +05:30
supplying the client information from `./static/fixtures/clients.json` into the flags.
2015-11-09 07:47:55 +05:30
2015-11-07 01:44:44 +05:30
```console
2015-11-09 07:47:55 +05:30
./bin/example-app \
--client-id=example-app \
2016-08-12 01:23:48 +05:30
--client-secret=eZXhhbXBsZS1jbGktc2VjcmV0 \
2015-11-09 07:47:55 +05:30
--discovery=http://127.0.0.1:5556
```
Visit [http://localhost:5555 ](http://localhost:5555 ) in your browser and click "login" link.
2015-11-07 01:44:44 +05:30
Next click "Login with Email" and enter the sample credentials from `static/fixtures/connectors.json` :
2015-11-09 07:47:55 +05:30
2015-11-07 01:44:44 +05:30
* email: `elroy77@example.com`
* password: `bones`
2015-11-09 07:47:55 +05:30
The example app will dump out details of the JWT issued by Dex which means that authentication was successful and the application has authenticated you as a valid user.
You can play with adding additional users in connectors.json and users.json.
## Example CLI Client
The example CLI will start, connect to the Dex instance to gather discovery information, listen on `localhost:8000` , and then acquire a client credentials JWT and print it out.
2015-11-07 01:44:44 +05:30
```console
2015-11-09 07:47:55 +05:30
./bin/example-cli \
2016-04-21 00:23:36 +05:30
--client-id example-cli \
2016-08-12 01:23:48 +05:30
--client-secret ZXhhbXBsZS1jbGktc2VjcmV0 \
2015-11-09 07:47:55 +05:30
--discovery=http://127.0.0.1:5556
```