Skip to content

Commit

Permalink
feat: update getting-started guide supporting authentication
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Becker <[email protected]>
  • Loading branch information
sbckr committed May 29, 2024
1 parent 96eec82 commit 5e00844
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 8 deletions.
59 changes: 59 additions & 0 deletions docs/documentation/getting-started/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
In this guide, you will learn how to download and configure the Carbyne Stack
CLI that can be used to interact with a virtual cloud from the command line.

!!! info
This guide expects Carbyne Stack to be deployed in a _local_ two player

Check notice on line 7 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L7

Expected: 0 or 2; Actual: 1
setting using kind clusters as described in the

Check notice on line 8 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L8

Expected: 0 or 2; Actual: 1
[manual deploymend guide](../deployment/manual). Cluster names as used for
connecting to the clusters may be different for individual deployments.

1. Install the CLI using:

```shell
Expand All @@ -18,6 +24,21 @@ CLI that can be used to interact with a virtual cloud from the command line.
export STARBUCK_FQDN="172.18.2.128.sslip.io"
```

1. Export the Thymus OAuth2 client IDs for both VCPs.

!!! info
Thymus automatically registers an OAuth2 client for authentication with
the Carbyne Stack VCP and stores its ID as a k8s secret called

Check notice on line 31 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L31

Expected: 0 or 2; Actual: 1
`thymus-client-secret`. For more information about OAuth2 clients see the
[Ory Hydry documentation](https://www.ory.sh/docs/hydra/guides/oauth2-clients).

```shell
kubectl config use-context kind-apollo
export APOLLO_OAUTH2_CLIENT_ID=$(kubectl get secret thymus-client-secret --template {{.data.CLIENT_ID}} | base64 -d)

Check notice on line 37 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L37

Expected: 80; Actual: 120
kubectl config use-context kind-starbuck
export STARBUCK_OAUTH2_CLIENT_ID=$(kubectl get secret thymus-client-secret --template {{.data.CLIENT_ID}} | base64 -d)

Check notice on line 39 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L39

Expected: 80; Actual: 122
```

1. Next, configure the CLI to talk to the virtual cloud you just deployed by
creating a matching CLI configuration file in `~/.cs` using:

Expand All @@ -33,12 +54,20 @@ CLI that can be used to interact with a virtual cloud from the command line.
"amphoraServiceUrl" : "http://$APOLLO_FQDN/amphora",
"castorServiceUrl" : "http://$APOLLO_FQDN/castor",
"ephemeralServiceUrl" : "http://$APOLLO_FQDN/",
"oauth2ClientId": "$APOLLO_OAUTH2_CLIENT_ID",
"oauth2AuthEndpointUri": "http://$APOLLO_FQDN/iam/oauth/oauth2/auth",
"oauth2TokenEndpointUri": "http://$APOLLO_FQDN/iam/oauth/oauth2/token",
"oauth2CallbackUrl": "http://127.0.0.1:32768/callback",
"id" : 1,
"baseUrl" : "http://$APOLLO_FQDN/"
}, {
"amphoraServiceUrl" : "http://$STARBUCK_FQDN/amphora",
"castorServiceUrl" : "http://$STARBUCK_FQDN/castor",
"ephemeralServiceUrl" : "http://$STARBUCK_FQDN/",
"oauth2ClientId": "$STARBUCK_OAUTH2_CLIENT_ID",
"oauth2AuthEndpointUri": "http://$STARBUCK_FQDN/iam/oauth/oauth2/auth",
"oauth2TokenEndpointUri": "http://$STARBUCK_FQDN/iam/oauth/oauth2/token",
"oauth2CallbackUrl": "http://127.0.0.1:32768/callback",
"id" : 2,
"baseUrl" : "http://$STARBUCK_FQDN/"
} ],
Expand All @@ -55,6 +84,36 @@ CLI that can be used to interact with a virtual cloud from the command line.
java -jar cs.jar configure
```
1. Log in to the VCPs
With the user-facing endpoints being secured using _OAuth2.0_ and _OpenID

Check notice on line 89 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L89

Expected: 0 or 2; Actual: 1
Connect_, it is required to authenticate to the VCPs. This can be done

Check notice on line 90 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L90

Expected: 0 or 2; Actual: 1
using:
```shell
java -jar cs.jar login
```
!!! info
The command above will open a browser window for each VCPs and prompt for

Check notice on line 98 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L98

Expected: 0 or 2; Actual: 1

Check notice on line 98 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L98

Expected: 80; Actual: 82
authentication.

Check notice on line 100 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L100

Expected: 0 or 2; Actual: 8
The development setup as described in the

Check notice on line 101 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L101

Expected: fenced; Actual: indented
[deployment tutorial](../deployment) will automatically register two
demo users as follows:
| E-Mail | Password |
| ------ | -------- |
| [email protected] | 2#Tv91*d-Z,M |
| [email protected] | 86KIo6<]!/V= |
!!! warning
If you register individual users, you must ensure that the users are

Check notice on line 111 in docs/documentation/getting-started/cli.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/cli.md#L111

Expected: 0 or 2; Actual: 1
registered in all VCPs with the same e-mail address. Passwords can be
set individually.
1. [_Optional_] Verify the configuration
You can verify that the configuration works by fetching telemetry data from
castor using:
Expand Down
8 changes: 4 additions & 4 deletions docs/documentation/getting-started/deployment/manual/stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ clusters using the kind tool as described in the
cd carbynestack/deployments
```

1. Checkout Carbyne Stack SDK version 0.5.0 using:
1. Checkout Carbyne Stack SDK version 0.6.0 using:

```shell
git checkout sdk-v0.5.0
git checkout sdk-v0.6.0
```

1. Before deploying the virtual cloud providers make some common configuration
Expand Down Expand Up @@ -119,7 +119,7 @@ clusters using the kind tool as described in the
export IS_MASTER=false
export AMPHORA_VC_PARTNER_URI=http://$APOLLO_FQDN/amphora
kubectl config use-context kind-starbuck
helmfile apply
helmfile sync --set thymus.users.enabled=true
```

1. Launch the `apollo` VCP using:
Expand All @@ -130,7 +130,7 @@ clusters using the kind tool as described in the
export AMPHORA_VC_PARTNER_URI=http://$STARBUCK_FQDN/amphora
export CASTOR_SLAVE_URI=http://$STARBUCK_FQDN/castor
kubectl config use-context kind-apollo
helmfile apply
helmfile sync --set thymus.users.enabled=true
```

1. Wait until all pods in both clusters are in the `ready` state.
Expand Down
34 changes: 30 additions & 4 deletions docs/documentation/getting-started/millionaires.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ these.

In addition, this guide assumes that you have the following tools installed:

- Java 8 (newer versions will not work)
- Java 11 (newer versions will not work)

## The Billionaires Problem

Expand All @@ -31,14 +31,37 @@ see how things work, let's put ourselves in Elon's shoes.
First, we upload the inputs into the Carbyne Stack
[Amphora Secret Store](https://github.com/carbynestack/amphora). The inputs are
the billionaires' net worth in billions. Note that this obviously has to be done
in a private way by Jeff and Elon in a real-world setting.
in a private way by Jeff and Elon in a real-world setting, simplified here by

Check notice on line 34 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L34

Expected: 0 or 2; Actual: 1
logging in as individual users.

The first secret will be uploaded with the identity of Jeff. To do so please

Check notice on line 37 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L37

Expected: 0 or 2; Actual: 1
perform the following commands and login as Jeff using the E-Mail
`[email protected]` and password `86KIo6<]!/V=`.


```shell
java -jar cs.jar login
# Create a secret representing Jeff's net worth (note that we work with
# billion USD here)
export JEFFS_NET_WORTH_ID=$(java -jar cs.jar amphora create-secret 177 -t billionaire=Jeff)
```

!!! info
If you have authenticated yourself to the VCPs recently, your previous

Check notice on line 50 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L50

Expected: 0 or 2; Actual: 1
session might still be cached using a browser cookie.

# And another one for Elon
If you are not prompted for your credentials and not logged in as the

Check notice on line 53 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L53

Expected: fenced; Actual: indented
desired user, please make sure to clear recent browser cache or cookies,
or re-open the tabs in private mode.

Next we will log in as Elon to perform the remaining steps of the tutorial. The
credentials for the development user Elon are as follows: <br>

Check notice on line 58 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L58

Element: br
&ensp;&ensp;&ensp;&ensp;E-Mail: `[email protected]`Password: `2#Tv91*d-Z,M`. <br>

Check notice on line 59 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L59

Element: br
(Please read the info box above if you are having trubles logging in as a different user.)

Check notice on line 60 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L60

Expected: 80; Actual: 90

```shell
java -jar cs.jar login
# And a secret for Elon
export ELONS_NET_WORTH_ID=$(java -jar cs.jar amphora create-secret 151 -t billionaire=Elon)
```

Expand All @@ -51,7 +74,10 @@ java -jar cs.jar amphora get-secrets
The output should resemble the following:

!!! note
The output you see will differ wrt. identifiers and the `creation-date` tag.
The output you see will differ wrt. identifiers and the `creation-date` tag. <br>

Check notice on line 77 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L77

Element: br

Check notice on line 77 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L77

Expected: 80; Actual: 85
Nevertheless, it will output both secrets, uploaded by Elon and Jeff even though
we are authenticated as Elon. This is to the fact of authentication, but not

Check notice on line 79 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L79

Expected: 0 or 2; Actual: 1

Check notice on line 79 in docs/documentation/getting-started/millionaires.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

docs/documentation/getting-started/millionaires.md#L79

Expected: 80; Actual: 81
authorization being integrated into Carbyne Stack for the time beeing.

```shell
ab160f93-3b7e-468f-b687-f9c46fb535f3
Expand Down

0 comments on commit 5e00844

Please sign in to comment.