Skip to content

Commit 6e3169f

Browse files
committed
remove docs from PR
Signed-off-by: Jorge Turrado <[email protected]>
1 parent dc427ec commit 6e3169f

File tree

4 files changed

+11
-83
lines changed

4 files changed

+11
-83
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- `core`:
66
- [v0.21.0](core/CHANGELOG.md#v0210)
77
- **Chore:** Use `jwt-bearer` grant to get a fresh token instead of `refresh_token`
8+
- **Feature:** Support Workload Identity Federation flow
89
- `sfs`:
910
- [v0.2.0](services/sfs/CHANGELOG.md)
1011
- **Breaking change:** Remove region configuration in `APIClient`

README.md

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

106106
The SDK supports two authentication methods:
107107

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)
108+
1. **Key Flow** (Recommended)
116109

117110
- Uses RSA key-pair based authentication
118111
- Provides better security through short-lived tokens
119112
- Supports both STACKIT-generated and custom key pairs
120113

121-
3. **Token Flow**
114+
2. **Token Flow**
122115
- Uses long-lived service account tokens
123116
- Simpler but less secure
124117

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

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

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-
```
126+
For each authentication method, the key flow is attempted first, followed by the token flow.
166127

167128
### Using the Key Flow
168129

@@ -273,4 +234,4 @@ See the [release documentation](./RELEASE.md) for further information.
273234

274235
## License
275236

276-
Apache 2.0
237+
Apache 2.0

core/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
## v0.18.0
1515
- **New:** Added duration utils
16-
- **Chore:** Use `jwt-bearer` grant to get a fresh token instead of `refresh_token`
1716

1817
## v0.17.3
1918
- **Dependencies:** Bump `github.com/golang-jwt/jwt/v5` from `v5.2.2` to `v5.2.3`

examples/authentication/authentication.go

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ func main() {
1414

1515
// When creating a new API client without providing any configuration, it will setup default authentication.
1616
// The SDK will search for a valid service account key or token in several locations.
17-
// It will first try to use the workload identity federation flow by looking into the variables STACKIT_FEDERATED_TOKEN_FILE, STACKIT_SERVICE_ACCOUNT_EMAIL and their default values,
18-
// Then, it will try key flow, by looking into the variables STACKIT_SERVICE_ACCOUNT_KEY, STACKIT_SERVICE_ACCOUNT_KEY_PATH,
17+
// It will first try to use the key flow, by looking into the variables STACKIT_SERVICE_ACCOUNT_KEY, STACKIT_SERVICE_ACCOUNT_KEY_PATH,
1918
// STACKIT_PRIVATE_KEY and STACKIT_PRIVATE_KEY_PATH. If the keys cannot be retrieved, it will check the credentials file located in STACKIT_CREDENTIALS_PATH, if specified, or in
2019
// $HOME/.stackit/credentials.json as a fallback. If the key are found and are valid, the KeyAuth flow is used.
2120
// If the key flow cannot be used, it will try to find a token in the STACKIT_SERVICE_ACCOUNT_TOKEN. If not present, it will
@@ -36,27 +35,18 @@ func main() {
3635

3736
// Create a new API client, that will authenticate using the provided bearer token
3837
token := "TOKEN"
39-
dnsClient, err := dns.NewAPIClient(config.WithToken(token))
38+
_, err = dns.NewAPIClient(config.WithToken(token))
4039
if err != nil {
4140
fmt.Fprintf(os.Stderr, "[DNS API] Creating API client: %v\n", err)
4241
os.Exit(1)
4342
}
4443

45-
// Check that you can make an authenticated request
46-
getZoneResp, err := dnsClient.ListZones(context.Background(), projectId).Execute()
47-
48-
if err != nil {
49-
fmt.Fprintf(os.Stderr, "[DNS API] Error when calling `ZoneApi.GetZones`: %v\n", err)
50-
} else {
51-
fmt.Printf("[DNS API] Number of zones: %v\n", len(*getZoneResp.Zones))
52-
}
53-
5444
// Create a new API client, that will authenticate using the key flow
5545
// If you created a service account key and provided your own RSA key pair,
5646
// you need to add the path to a PEM encoded file including the private key
5747
// using config.WithPrivateKeyPath("path/to/private_key.pem")
5848
saKeyPath := "/path/to/service_account_key.json"
59-
dnsClient, err = dns.NewAPIClient(
49+
dnsClient, err := dns.NewAPIClient(
6050
config.WithServiceAccountKeyPath(saKeyPath),
6151
)
6252
if err != nil {
@@ -65,34 +55,11 @@ func main() {
6555
}
6656

6757
// Check that you can make an authenticated request
68-
getZoneResp, err = dnsClient.ListZones(context.Background(), projectId).Execute()
69-
70-
if err != nil {
71-
fmt.Fprintf(os.Stderr, "[DNS API] Error when calling `ZoneApi.GetZones`: %v\n", err)
72-
} else {
73-
fmt.Printf("[DNS API] Number of zones: %v\n", len(*getZoneResp.Zones))
74-
}
75-
76-
// Create a new API client, that will authenticate using the wif flow
77-
// You need to create a service account key and configure the federate identity provider,
78-
// then you can init the SDK setting fields
79-
dnsClient, err = dns.NewAPIClient(
80-
config.WithWorkloadIdentityFederationAuth(),
81-
config.WithTokenEndpoint("custom token endpoint"),
82-
config.WithWorkloadIdentityFederationTokenPath("/path/to/your/federated/token"),
83-
config.WithServiceAccountEmail("[email protected]"),
84-
)
85-
if err != nil {
86-
fmt.Fprintf(os.Stderr, "[DNS API] Creating API client: %v\n", err)
87-
os.Exit(1)
88-
}
89-
90-
// Check that you can make an authenticated request
91-
getZoneResp, err = dnsClient.ListZones(context.Background(), projectId).Execute()
58+
getZoneResp, err := dnsClient.ListZones(context.Background(), projectId).Execute()
9259

9360
if err != nil {
9461
fmt.Fprintf(os.Stderr, "[DNS API] Error when calling `ZoneApi.GetZones`: %v\n", err)
9562
} else {
9663
fmt.Printf("[DNS API] Number of zones: %v\n", len(*getZoneResp.Zones))
9764
}
98-
}
65+
}

0 commit comments

Comments
 (0)