Skip to content

Commit 6281701

Browse files
authored
remove deprecated jwks endpoint (#459)
1 parent a10c4a5 commit 6281701

File tree

8 files changed

+5
-57
lines changed

8 files changed

+5
-57
lines changed

docs/stackit_config_set.md

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ stackit config set [flags]
3636
--iaas-custom-endpoint string IaaS API base URL, used in calls to this API
3737
--identity-provider-custom-client-id string Identity Provider client ID, used for user authentication
3838
--identity-provider-custom-endpoint string Identity Provider base URL, used for user authentication
39-
--jwks-custom-endpoint string Custom endpoint for the jwks API, which is used to get the json web key sets (jwks) to validate tokens when the service-account authentication is activated
4039
--load-balancer-custom-endpoint string Load Balancer API base URL, used in calls to this API
4140
--logme-custom-endpoint string LogMe API base URL, used in calls to this API
4241
--mariadb-custom-endpoint string MariaDB API base URL, used in calls to this API

docs/stackit_config_unset.md

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ stackit config unset [flags]
3434
--iaas-custom-endpoint IaaS API base URL. If unset, uses the default base URL
3535
--identity-provider-custom-client-id Identity Provider client ID, used for user authentication
3636
--identity-provider-custom-endpoint Identity Provider base URL. If unset, uses the default base URL
37-
--jwks-custom-endpoint Custom endpoint for the jwks API, which is used to get the json web key sets (jwks) to validate tokens when the service-account authentication is activated
3837
--load-balancer-custom-endpoint Load Balancer API base URL. If unset, uses the default base URL
3938
--logme-custom-endpoint LogMe API base URL. If unset, uses the default base URL
4039
--mariadb-custom-endpoint MariaDB API base URL. If unset, uses the default base URL

internal/cmd/auth/activate-service-account/activate_service_account.go

+4-10
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
5454
RunE: func(cmd *cobra.Command, args []string) error {
5555
model := parseInput(p, cmd)
5656

57-
tokenCustomEndpoint, jwksCustomEndpoint, err := storeFlags()
57+
tokenCustomEndpoint, err := storeFlags()
5858
if err != nil {
5959
return err
6060
}
@@ -64,7 +64,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
6464
ServiceAccountKeyPath: model.ServiceAccountKeyPath,
6565
PrivateKeyPath: model.PrivateKeyPath,
6666
TokenCustomUrl: tokenCustomEndpoint,
67-
JWKSCustomUrl: jwksCustomEndpoint,
6867
}
6968

7069
// Setup authentication based on the provided credentials and the environment
@@ -119,17 +118,12 @@ func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel {
119118
return &model
120119
}
121120

122-
func storeFlags() (tokenCustomEndpoint, jwksCustomEndpoint string, err error) {
121+
func storeFlags() (tokenCustomEndpoint string, err error) {
123122
tokenCustomEndpoint = viper.GetString(config.TokenCustomEndpointKey)
124-
jwksCustomEndpoint = viper.GetString(config.JwksCustomEndpointKey)
125123

126124
err = auth.SetAuthField(auth.TOKEN_CUSTOM_ENDPOINT, tokenCustomEndpoint)
127125
if err != nil {
128-
return "", "", fmt.Errorf("set %s: %w", auth.TOKEN_CUSTOM_ENDPOINT, err)
126+
return "", fmt.Errorf("set %s: %w", auth.TOKEN_CUSTOM_ENDPOINT, err)
129127
}
130-
err = auth.SetAuthField(auth.JWKS_CUSTOM_ENDPOINT, jwksCustomEndpoint)
131-
if err != nil {
132-
return "", "", fmt.Errorf("set %s: %w", auth.JWKS_CUSTOM_ENDPOINT, err)
133-
}
134-
return tokenCustomEndpoint, jwksCustomEndpoint, nil
128+
return tokenCustomEndpoint, nil
135129
}

internal/cmd/auth/activate-service-account/activate_service_account_test.go

+1-18
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
)
1515

1616
var testTokenCustomEndpoint = "token_url"
17-
var testJwksCustomEndpoint = "jwks_url"
1817

1918
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2019
flagValues := map[string]string{
@@ -45,23 +44,20 @@ func TestParseInput(t *testing.T) {
4544
description string
4645
flagValues map[string]string
4746
tokenCustomEndpoint string
48-
jwksCustomEndpoint string
4947
isValid bool
5048
expectedModel *inputModel
5149
}{
5250
{
5351
description: "base",
5452
flagValues: fixtureFlagValues(),
5553
tokenCustomEndpoint: testTokenCustomEndpoint,
56-
jwksCustomEndpoint: testJwksCustomEndpoint,
5754
isValid: true,
5855
expectedModel: fixtureInputModel(),
5956
},
6057
{
6158
description: "no values",
6259
flagValues: map[string]string{},
6360
tokenCustomEndpoint: "",
64-
jwksCustomEndpoint: "",
6561
isValid: true,
6662
expectedModel: &inputModel{
6763
ServiceAccountToken: "",
@@ -77,7 +73,6 @@ func TestParseInput(t *testing.T) {
7773
privateKeyPathFlag: "",
7874
},
7975
tokenCustomEndpoint: "",
80-
jwksCustomEndpoint: "",
8176
isValid: true,
8277
expectedModel: &inputModel{
8378
ServiceAccountToken: "",
@@ -131,14 +126,12 @@ func TestStoreFlags(t *testing.T) {
131126
description string
132127
model *inputModel
133128
tokenCustomEndpoint string
134-
jwksCustomEndpoint string
135129
isValid bool
136130
}{
137131
{
138132
description: "base",
139133
model: fixtureInputModel(),
140134
tokenCustomEndpoint: testTokenCustomEndpoint,
141-
jwksCustomEndpoint: testJwksCustomEndpoint,
142135
isValid: true,
143136
},
144137
{
@@ -149,7 +142,6 @@ func TestStoreFlags(t *testing.T) {
149142
PrivateKeyPath: "",
150143
},
151144
tokenCustomEndpoint: "",
152-
jwksCustomEndpoint: "",
153145
isValid: true,
154146
},
155147
}
@@ -161,9 +153,8 @@ func TestStoreFlags(t *testing.T) {
161153

162154
viper.Reset()
163155
viper.Set(config.TokenCustomEndpointKey, tt.tokenCustomEndpoint)
164-
viper.Set(config.JwksCustomEndpointKey, tt.jwksCustomEndpoint)
165156

166-
tokenCustomEndpoint, jwksCustomEndpoint, err := storeFlags()
157+
tokenCustomEndpoint, err := storeFlags()
167158
if !tt.isValid {
168159
if err == nil {
169160
t.Fatalf("did not fail on invalid input")
@@ -181,14 +172,6 @@ func TestStoreFlags(t *testing.T) {
181172
if value != tokenCustomEndpoint {
182173
t.Errorf("Value of \"%s\" does not match: expected \"%s\", got \"%s\"", auth.TOKEN_CUSTOM_ENDPOINT, tokenCustomEndpoint, value)
183174
}
184-
185-
value, err = auth.GetAuthField(auth.JWKS_CUSTOM_ENDPOINT)
186-
if err != nil {
187-
t.Errorf("Failed to get value of auth field: %v", err)
188-
}
189-
if value != jwksCustomEndpoint {
190-
t.Errorf("Value of \"%s\" does not match: expected \"%s\", got \"%s\"", auth.JWKS_CUSTOM_ENDPOINT, jwksCustomEndpoint, value)
191-
}
192175
})
193176
}
194177
}

internal/cmd/config/set/set.go

-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const (
4444
sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint"
4545
iaasCustomEndpointFlag = "iaas-custom-endpoint"
4646
tokenCustomEndpointFlag = "token-custom-endpoint"
47-
jwksCustomEndpointFlag = "jwks-custom-endpoint"
4847
)
4948

5049
type inputModel struct {
@@ -157,7 +156,6 @@ func configureFlags(cmd *cobra.Command) {
157156
cmd.Flags().String(sqlServerFlexCustomEndpointFlag, "", "SQLServer Flex API base URL, used in calls to this API")
158157
cmd.Flags().String(iaasCustomEndpointFlag, "", "IaaS API base URL, used in calls to this API")
159158
cmd.Flags().String(tokenCustomEndpointFlag, "", "Custom endpoint for the token API, which is used to request access tokens when the service-account authentication is activated")
160-
cmd.Flags().String(jwksCustomEndpointFlag, "", "Custom endpoint for the jwks API, which is used to get the json web key sets (jwks) to validate tokens when the service-account authentication is activated")
161159

162160
err := viper.BindPFlag(config.SessionTimeLimitKey, cmd.Flags().Lookup(sessionTimeLimitFlag))
163161
cobra.CheckErr(err)
@@ -212,8 +210,6 @@ func configureFlags(cmd *cobra.Command) {
212210
cobra.CheckErr(err)
213211
err = viper.BindPFlag(config.TokenCustomEndpointKey, cmd.Flags().Lookup(tokenCustomEndpointFlag))
214212
cobra.CheckErr(err)
215-
err = viper.BindPFlag(config.JwksCustomEndpointKey, cmd.Flags().Lookup(jwksCustomEndpointFlag))
216-
cobra.CheckErr(err)
217213
}
218214

219215
func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {

internal/cmd/config/unset/unset.go

-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const (
4747
sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint"
4848
iaasCustomEndpointFlag = "iaas-custom-endpoint"
4949
tokenCustomEndpointFlag = "token-custom-endpoint"
50-
jwksCustomEndpointFlag = "jwks-custom-endpoint"
5150
)
5251

5352
type inputModel struct {
@@ -83,7 +82,6 @@ type inputModel struct {
8382
SQLServerFlexCustomEndpoint bool
8483
IaaSCustomEndpoint bool
8584
TokenCustomEndpoint bool
86-
JwksCustomEndpoint bool
8785
}
8886

8987
func NewCmd(p *print.Printer) *cobra.Command {
@@ -198,9 +196,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
198196
if model.TokenCustomEndpoint {
199197
viper.Set(config.TokenCustomEndpointKey, "")
200198
}
201-
if model.JwksCustomEndpoint {
202-
viper.Set(config.JwksCustomEndpointKey, "")
203-
}
204199

205200
err := config.Write()
206201
if err != nil {
@@ -246,7 +241,6 @@ func configureFlags(cmd *cobra.Command) {
246241
cmd.Flags().Bool(sqlServerFlexCustomEndpointFlag, false, "SQLServer Flex API base URL. If unset, uses the default base URL")
247242
cmd.Flags().Bool(iaasCustomEndpointFlag, false, "IaaS API base URL. If unset, uses the default base URL")
248243
cmd.Flags().Bool(tokenCustomEndpointFlag, false, "Custom endpoint for the token API, which is used to request access tokens when the service-account authentication is activated")
249-
cmd.Flags().Bool(jwksCustomEndpointFlag, false, "Custom endpoint for the jwks API, which is used to get the json web key sets (jwks) to validate tokens when the service-account authentication is activated")
250244
}
251245

252246
func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel {
@@ -283,7 +277,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel {
283277
SQLServerFlexCustomEndpoint: flags.FlagToBoolValue(p, cmd, sqlServerFlexCustomEndpointFlag),
284278
IaaSCustomEndpoint: flags.FlagToBoolValue(p, cmd, iaasCustomEndpointFlag),
285279
TokenCustomEndpoint: flags.FlagToBoolValue(p, cmd, tokenCustomEndpointFlag),
286-
JwksCustomEndpoint: flags.FlagToBoolValue(p, cmd, jwksCustomEndpointFlag),
287280
}
288281

289282
if p.IsVerbosityDebug() {

internal/cmd/config/unset/unset_test.go

-13
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func fixtureFlagValues(mods ...func(flagValues map[string]bool)) map[string]bool
4040
sqlServerFlexCustomEndpointFlag: true,
4141
iaasCustomEndpointFlag: true,
4242
tokenCustomEndpointFlag: true,
43-
jwksCustomEndpointFlag: true,
4443
}
4544
for _, mod := range mods {
4645
mod(flagValues)
@@ -79,7 +78,6 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
7978
SQLServerFlexCustomEndpoint: true,
8079
IaaSCustomEndpoint: true,
8180
TokenCustomEndpoint: true,
82-
JwksCustomEndpoint: true,
8381
}
8482
for _, mod := range mods {
8583
mod(model)
@@ -134,7 +132,6 @@ func TestParseInput(t *testing.T) {
134132
model.SQLServerFlexCustomEndpoint = false
135133
model.IaaSCustomEndpoint = false
136134
model.TokenCustomEndpoint = false
137-
model.JwksCustomEndpoint = false
138135
}),
139136
},
140137
{
@@ -277,16 +274,6 @@ func TestParseInput(t *testing.T) {
277274
model.TokenCustomEndpoint = false
278275
}),
279276
},
280-
{
281-
description: "jwks custom endpoint empty",
282-
flagValues: fixtureFlagValues(func(flagValues map[string]bool) {
283-
flagValues[jwksCustomEndpointFlag] = false
284-
}),
285-
isValid: true,
286-
expectedModel: fixtureInputModel(func(model *inputModel) {
287-
model.JwksCustomEndpoint = false
288-
}),
289-
},
290277
}
291278
for _, tt := range tests {
292279
t.Run(tt.description, func(t *testing.T) {

internal/pkg/config/config.go

-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const (
4343
SQLServerFlexCustomEndpointKey = "sqlserverflex_custom_endpoint"
4444
IaaSCustomEndpointKey = "iaas_custom_endpoint"
4545
TokenCustomEndpointKey = "token_custom_endpoint"
46-
JwksCustomEndpointKey = "jwks_custom_endpoint"
4746

4847
ProjectNameKey = "project_name"
4948
DefaultProfileName = "default"
@@ -99,7 +98,6 @@ var ConfigKeys = []string{
9998
SQLServerFlexCustomEndpointKey,
10099
IaaSCustomEndpointKey,
101100
TokenCustomEndpointKey,
102-
JwksCustomEndpointKey,
103101
}
104102

105103
var defaultConfigFolderPath string
@@ -177,7 +175,6 @@ func setConfigDefaults() {
177175
viper.SetDefault(SQLServerFlexCustomEndpointKey, "")
178176
viper.SetDefault(IaaSCustomEndpointKey, "")
179177
viper.SetDefault(TokenCustomEndpointKey, "")
180-
viper.SetDefault(JwksCustomEndpointKey, "")
181178
}
182179

183180
func getConfigFilePath(configFolder string) string {

0 commit comments

Comments
 (0)