Skip to content

Commit

Permalink
Rework spring-security-basic-auth samples instructions
Browse files Browse the repository at this point in the history
Also: fix k8s build
  • Loading branch information
kuntzed committed Oct 18, 2024
1 parent edb0d78 commit 3a0eb2e
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 204 deletions.
69 changes: 8 additions & 61 deletions docs/HowToFetchToken.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Get your service configuration:
- In CF from [VCAP_SERVICES](https://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html#VCAP-SERVICES) environment variable
- In K8s/Kyma from configuration [secrets](https://kubernetes.io/docs/concepts/configuration/secret/)

The documentation assumes the utility `curl` and `awk` to be installed (Mac OS: brew install curl, Ubuntu: sudo apt-get install curl). Alternatively, use [Postman Rest Client](https://www.postman.com/downloads/).
The documentation assumes the utilities `curl` and `awk` to be installed (Mac OS: brew install curl, Ubuntu: sudo apt-get install curl).

## IAS Tokens
<details>
Expand All @@ -16,11 +16,6 @@ The documentation assumes the utility `curl` and `awk` to be installed (Mac OS:
> ```
2. Fetch the token using:
<details>
<summary>curl command</summary>
:warning: Replace the `<<>>` placeholders with the values from the service configuration.
```shell
curl --cert certificate.pem --key key.pem \
-X POST <<credentials.url>>/oauth2/token \
Expand All @@ -30,26 +25,12 @@ The documentation assumes the utility `curl` and `awk` to be installed (Mac OS:
--data-urlencode 'username=<<name of requesting user>>' \
--data-urlencode 'password=<<password of requesting user>>'
```
</details>
<details>
<summary>Postman</summary>
1. In Postman navigate to Settings -> Certificates, click on "Add Certificate" and provide the certificate and key `PEM` files and host name.
<br>![](./postman-mtls.png)
2. Import [Postman Collection](./IAS_XSUAA_token_fetch.postman_collection.json). For more info on how to import it in the Postman see [learning.postman.com](https://learning.postman.com/docs/getting-started/importing-and-exporting-data/#importing-postman-data)
3. Fill in the corresponding ias_* Postman variables
<br>![](./postman-variables.png)
4. Open the 'IAS Token | pswd grant' Postman Collection and send the request
</details>
:grey_exclamation: Replace the `<<>>` placeholders with values from the service configuration and user credentials.
</details>
<details>
<summary>Using Client Credentials</summary>
1. Fetch the token using:
<details>
<summary>curl command</summary>
:warning: Replace the `<<>>` placeholders with the values from the service configuration.
```shell
curl -u '<<credentials.clientid>>:<<credentials.clientsecret>>' \
-X POST <<credentials.url>>/oauth2/token \
Expand All @@ -58,15 +39,7 @@ The documentation assumes the utility `curl` and `awk` to be installed (Mac OS:
--data-urlencode 'username=<<name of requesting user>>' \
--data-urlencode 'password=<<password of requesting user>>'
```
</details>
<details>
<summary>Postman</summary>
1. Import [Postman Collection](./IAS_XSUAA_token_fetch.postman_collection.json). For more info how to import it in Postman see [learning.postman.com](https://learning.postman.com/docs/getting-started/importing-and-exporting-data/#importing-postman-data)
2. Fill in the corresponding ias_* Postman variables
<br>![](./postman-variables.png)
3. Open the 'Ias Token | pswd grant' Postman Collection and send the request
</details>
:grey_exclamation: Replace the `<<>>` placeholders with values from the service configuration and user credentials.
</details>
## XSUAA Tokens
Expand All @@ -79,39 +52,21 @@ The documentation assumes the utility `curl` and `awk` to be installed (Mac OS:
> awk '{gsub(/\\n/,"\n")}1' <file>.pem
> ```
2. Fetch the token using:
<details>
<summary>curl command</summary>
:warning: Replace the `<<>>` placeholders with the values from the service configuration.
```shell
curl --cert certificate.pem --key key.pem \
-X POST <<credentials.certurl>>/oauth/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=<<credentials.clientid>>' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=<<name of requesting user>>' \
--data-urlencode 'password=<<password of requesting user>>'
--data-urlencode 'username=<<name of requesting user>>' \
--data-urlencode 'password=<<password of requesting user>>'
```
</details>
<details>
<summary>Postman</summary>
1. In Postman navigate to Settings -> Certificates, click on "Add Certificate" and provide the certificate and key `PEM` files and host name.
<br>![](./postman-mtls.png)
2. Import [Postman Collection](./IAS_XSUAA_token_fetch.postman_collection.json). For more info on how to import it in the Postman see [learning.postman.com](https://learning.postman.com/docs/getting-started/importing-and-exporting-data/#importing-postman-data)
3. Fill in the corresponding xsuaa_* Postman variables
<br>![](./postman-variables.png)
4. Open the 'Xsuaa Token | pswd grant mTLS' Postman Collection and send the request
</details>
:grey_exclamation: Replace the `<<>>` placeholders with values from the service configuration and user credentials.
</details>
<details>
<summary>Using Client Credentials</summary>
1. Fetch the token using:
<details>
<summary>curl command</summary>
:warning: Replace the `<<>>` placeholders with the values from the service configuration.
1. Fetch the token using:
```shell
curl \
-X POST <<credentials.url>>/oauth/token \
Expand All @@ -122,13 +77,5 @@ The documentation assumes the utility `curl` and `awk` to be installed (Mac OS:
--data-urlencode 'username=<<name of requesting user>>' \
--data-urlencode 'password=<<password of requesting user>>'
```
</details>
<details>
<summary>Postman</summary>
1. Import [Postman Collection](./IAS_XSUAA_token_fetch.postman_collection.json). For more info how to import it in Postman see [learning.postman.com](https://learning.postman.com/docs/getting-started/importing-and-exporting-data/#importing-postman-data)
2. Fill in the corresponding xsuaa_* Postman variables
<br>![](./postman-variables.png)
3. Open the 'Xsuaa Token | pswd grant' Postman Collection and send the request
</details>
:grey_exclamation: Replace the `<<>>` placeholders with values from the service configuration and user credentials.
</details>
Loading

0 comments on commit 3a0eb2e

Please sign in to comment.