Skip to content

Commit

Permalink
Issue#24 (#25)
Browse files Browse the repository at this point in the history
* fixed issue#24

* improve documenatation
  • Loading branch information
eabili0 authored Jan 16, 2020
1 parent 1c65f6c commit 4d7abae
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ if err == nil {

## Use as a CLI utility

The following command should get you started:
Run the dependencies:

```bash
./whisper-client --client-id teste --client-secret teste123 --whisper-url http://localhost:7070/ --redirect-uris http://redirect1,http://redirect2 --log-level debug --scopes test1,test2 > token.json
docker-compose up -d
```

Wait a few seconds to stabilize and then:

```bash
./whisper-client --client-id teste --client-secret teste123 --whisper-url http://localhost:7070/ --login-redirect-uri http://test.com/login --logout-redirect-uri http://test.com/logout --log-level debug --scopes offline,openid,test1,test2 > token.json
```

The command above will store the generated token as a file called `token.json`.
Expand Down
11 changes: 6 additions & 5 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import (
"context"
"crypto/tls"
"encoding/json"
"github.com/labbsr0x/goh/gohclient"
"github.com/labbsr0x/whisper-client/misc"
"github.com/sirupsen/logrus"
"golang.org/x/oauth2/clientcredentials"
"net/http"
"net/url"
"reflect"
"strings"

"github.com/labbsr0x/goh/gohclient"
"github.com/labbsr0x/whisper-client/misc"
"github.com/sirupsen/logrus"
"golang.org/x/oauth2/clientcredentials"

"github.com/gorilla/mux"
"github.com/labbsr0x/goh/gohtypes"

Expand Down Expand Up @@ -121,7 +122,7 @@ func (client *WhisperClient) IntrospectToken(token string) (result Token, err er
httpClient.ContentType = "application/x-www-form-urlencoded"
httpClient.Accept = "application/json"

payload := url.Values{"token": []string{token}, "scopes": client.hc.scopes}
payload := url.Values{"token": []string{token}, "scopes": []string{strings.Join(client.hc.scopes, " ")}}
payloadData := bytes.NewBufferString(payload.Encode()).Bytes()
logrus.Debugf("IntrospectToken - POST payload: '%v'", payloadData)

Expand Down
33 changes: 28 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
version: '3.5'

services:
whisper-client:

whisper:
build: .
image: labbsr0x/whisper-client:latest
image: labbsr0x/whisper:latest
depends_on:
- mysqld-whisper
- hydra
command:
/whisper-client --client-id teste --client-secret teste123 --hydra-admin-url http://hydra:4445/ --hydra-public-url http://hydra:4444/ --redirect-uris http://test.com,http://test1.com --log-level debug --scopes test1,test2 > token.json
ports:
- "7070:7070"
environment:
- WHISPER_PORT=7070
- WHISPER_LOG_LEVEL=debug
- WHISPER_HYDRA_ADMIN_URL=http://hydra:4445/
- WHISPER_HYDRA_PUBLIC_URL=http://hydra:4444/
- WHISPER_SECRET_KEY=uhSunsodnsuBsdjsbds
- WHISPER_DATABASE_URL=mysql://root:secret@tcp(mysqld-whisper:3306)/whisper?charset=utf8mb4&parseTime=True&loc=Local
- WHISPER_MAIL_USER=628ecbe7f53ac2
- WHISPER_MAIL_PASSWORD=457cd26e7890c5
- WHISPER_MAIL_HOST=smtp.mailtrap.io
- WHISPER_MAIL_PORT=2525
- WHISPER_PUBLIC_URL=http://localhost:7070
restart: on-failure

hydra-migrate:
Expand Down Expand Up @@ -50,7 +64,16 @@ services:
mysqld:
image: mysql:5.7
ports:
- "3306:3306"
- 3306
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_DATABASE=hydra

mysqld-whisper:
image: mysql:5.7
ports:
- 3306
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_DATABASE=whisper

0 comments on commit 4d7abae

Please sign in to comment.