Skip to content

Commit 5af53b2

Browse files
committed
apply feedback
Signed-off-by: Jorge Turrado <[email protected]>
1 parent c00e7f0 commit 5af53b2

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

README.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,20 @@ To authenticate with the SDK, you need a [service account](https://docs.stackit.
105105

106106
The SDK supports two authentication methods:
107107

108-
1. **Key Flow** (Recommended)
108+
1. **Workload Identity Federation Flow** (Recommended)
109+
110+
- Uses OIDC trusted tokens
111+
- Provides best security through short-lived tokens without secrets
112+
113+
> NOTE: This flow isn't publicly available yet. It'll be public during Q1 2026
114+
115+
2. **Key Flow** (Recommended)
109116

110117
- Uses RSA key-pair based authentication
111118
- Provides better security through short-lived tokens
112119
- Supports both STACKIT-generated and custom key pairs
113120

114-
2. **Token Flow**
121+
3. **Token Flow**
115122
- Uses long-lived service account tokens
116123
- Simpler but less secure
117124

@@ -120,10 +127,42 @@ The SDK supports two authentication methods:
120127
The SDK searches for credentials in the following order:
121128

122129
1. Explicit configuration in code
123-
2. Environment variables (KEY_PATH for KEY)
130+
2. Environment variables
124131
3. Credentials file (`$HOME/.stackit/credentials.json`)
125132

126-
For each authentication method, the key flow is attempted first, followed by the token flow.
133+
For each authentication method, the try order is:
134+
1. Workload Identity Federation Flow
135+
2. Key Flow
136+
3. Token Flow
137+
138+
### Using the Workload Identity Fedearion Flow
139+
140+
1. Create a service account trusted relation in the STACKIT Portal:
141+
142+
- Navigate to `Service Accounts` → Select account → `Federated Identity Providers` → Add a Federated Identity Provider
143+
- Configure the trusted issuer and the required assertions to trust in. (Link to official docs here after GA)
144+
145+
2. Configure authentication using any of these methods:
146+
147+
**A. Code Configuration**
148+
149+
```go
150+
// Using wokload identity federation flow
151+
config.WithWorkloadIdentityFederationAuth()
152+
// With the custom path for the external OIDC token
153+
config.WithWorkloadIdentityFederationTokenPath("/path/to/your/federated/token")
154+
// For the service account
155+
config.WithServiceAccountEmail("[email protected]")
156+
```
157+
158+
**B. Environment Variables**
159+
160+
```bash
161+
# With the custom path for the external OIDC token
162+
STACKIT_FEDERATED_TOKEN_FILE=/path/to/your/federated/token
163+
# For the service account
164+
165+
```
127166

128167
### Using the Key Flow
129168

examples/authentication/authentication.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,6 @@ func main() {
7272
fmt.Printf("[DNS API] Number of zones: %v\n", len(*getZoneResp.Zones))
7373
}
7474

75-
// Create a new API client, that will authenticate using the wif flow
76-
// You need to create a service account key and configure the federate identity provider,
77-
// then you can init the SDK using default env var
78-
os.Setenv("STACKIT_SERVICE_ACCOUNT_EMAIL", "[email protected]")
79-
os.Setenv("STACKIT_FEDERATED_TOKEN_FILE", "/path/to/your/federated/token") // Default "/var/run/secrets/stackit.cloud/serviceaccount/token"
80-
os.Setenv("STACKIT_IDP_ENDPOINT", "custom token endpoint") // Default "https://accounts.stackit.cloud/oauth/v2/token"
81-
dnsClient, err = dns.NewAPIClient()
82-
if err != nil {
83-
fmt.Fprintf(os.Stderr, "[DNS API] Creating API client: %v\n", err)
84-
os.Exit(1)
85-
}
86-
87-
// Check that you can make an authenticated request
88-
getZoneResp, err = dnsClient.ListZones(context.Background(), projectId).Execute()
89-
90-
if err != nil {
91-
fmt.Fprintf(os.Stderr, "[DNS API] Error when calling `ZoneApi.GetZones`: %v\n", err)
92-
} else {
93-
fmt.Printf("[DNS API] Number of zones: %v\n", len(*getZoneResp.Zones))
94-
}
95-
9675
// Create a new API client, that will authenticate using the wif flow
9776
// You need to create a service account key and configure the federate identity provider,
9877
// then you can init the SDK setting fields

0 commit comments

Comments
 (0)