Skip to content

Commit 1da91e2

Browse files
authored
Revert "Optionally Ignore trailing "/" at end of boundAudience (#323)" (#343)
This reverts commit e9b60da.
1 parent 4f51ed1 commit 1da91e2

File tree

2 files changed

+7
-109
lines changed

2 files changed

+7
-109
lines changed

path_role.go

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ func pathRole(b *jwtAuthBackend) *framework.Path {
9696
},
9797
"expiration_leeway": {
9898
Type: framework.TypeSignedDurationSecond,
99-
Description: `Duration in seconds of leeway when validating expiration of a token to account for clock skew.
99+
Description: `Duration in seconds of leeway when validating expiration of a token to account for clock skew.
100100
Defaults to 150 (2.5 minutes) if set to 0 and can be disabled if set to -1.`,
101101
Default: claimDefaultLeeway,
102102
},
103103
"not_before_leeway": {
104104
Type: framework.TypeSignedDurationSecond,
105-
Description: `Duration in seconds of leeway when validating not before values of a token to account for clock skew.
105+
Description: `Duration in seconds of leeway when validating not before values of a token to account for clock skew.
106106
Defaults to 150 (2.5 minutes) if set to 0 and can be disabled if set to -1.`,
107107
Default: claimDefaultLeeway,
108108
},
109109
"clock_skew_leeway": {
110110
Type: framework.TypeSignedDurationSecond,
111-
Description: `Duration in seconds of leeway when validating all claims to account for clock skew.
111+
Description: `Duration in seconds of leeway when validating all claims to account for clock skew.
112112
Defaults to 60 (1 minute) if set to 0 and can be disabled if set to -1.`,
113113
Default: jwt.DefaultLeeway,
114114
},
@@ -120,10 +120,6 @@ Defaults to 60 (1 minute) if set to 0 and can be disabled if set to -1.`,
120120
Type: framework.TypeCommaStringSlice,
121121
Description: `Comma-separated list of 'aud' claims that are valid for login; any match is sufficient`,
122122
},
123-
"bound_audience_disregard_trailing_slash": {
124-
Type: framework.TypeBool,
125-
Description: `If true, ignores the trailing slash in each bound audience when matching the audience claim in the token.`,
126-
},
127123
"bound_claims_type": {
128124
Type: framework.TypeString,
129125
Description: `How to interpret values in the map of claims/values (which must match for login): allowed values are 'string' or 'glob'`,
@@ -143,7 +139,7 @@ Defaults to 60 (1 minute) if set to 0 and can be disabled if set to -1.`,
143139
},
144140
"user_claim_json_pointer": {
145141
Type: framework.TypeBool,
146-
Description: `If true, the user_claim value will use JSON pointer syntax
142+
Description: `If true, the user_claim value will use JSON pointer syntax
147143
for referencing claims.`,
148144
},
149145
"groups_claim": {
@@ -160,13 +156,13 @@ for referencing claims.`,
160156
},
161157
"verbose_oidc_logging": {
162158
Type: framework.TypeBool,
163-
Description: `Log received OIDC tokens and claims when debug-level logging is active.
164-
Not recommended in production since sensitive information may be present
159+
Description: `Log received OIDC tokens and claims when debug-level logging is active.
160+
Not recommended in production since sensitive information may be present
165161
in OIDC responses.`,
166162
},
167163
"max_age": {
168164
Type: framework.TypeDurationSecond,
169-
Description: `Specifies the allowable elapsed time in seconds since the last time the
165+
Description: `Specifies the allowable elapsed time in seconds since the last time the
170166
user was actively authenticated.`,
171167
},
172168
},
@@ -462,26 +458,6 @@ func (b *jwtAuthBackend) pathRoleCreateUpdate(ctx context.Context, req *logical.
462458
role.BoundAudiences = boundAudiences.([]string)
463459
}
464460

465-
// disregard the trailing slash (if it exists) on all bound audiences if the flag is set
466-
if _, ok := data.GetOk("bound_audience_disregard_trailing_slash"); ok {
467-
boundAudiences := []string{}
468-
processed := map[string]bool{} // used to prevent duplicate entries
469-
470-
for _, audience := range role.BoundAudiences {
471-
// trim the trailing slash from the audience if it exists
472-
audienceWithoutTrailingSlash := strings.TrimRight(audience, "/")
473-
474-
// add the audience to the list of bound audiences if the audience
475-
// without the trailing slash has not already been processed
476-
if _, ok := processed[audienceWithoutTrailingSlash]; !ok {
477-
boundAudiences = append(boundAudiences, audienceWithoutTrailingSlash)
478-
processed[audienceWithoutTrailingSlash] = true
479-
}
480-
}
481-
482-
role.BoundAudiences = boundAudiences
483-
}
484-
485461
if boundSubject, ok := data.GetOk("bound_subject"); ok {
486462
role.BoundSubject = boundSubject.(string)
487463
}

path_role_test.go

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -516,84 +516,6 @@ func TestPath_Create(t *testing.T) {
516516
t.Fatalf("unexpected err: %v", resp)
517517
}
518518
})
519-
520-
t.Run("audiences have trailing slash removed if exists", func(t *testing.T) {
521-
b, storage := getBackend(t)
522-
originalAudiences := []string{"audience-1/", "audience-2/", "audience-3"}
523-
524-
data := map[string]interface{}{
525-
"role_type": "jwt",
526-
"user_claim": "user",
527-
"policies": "test",
528-
"bound_audiences": strings.Join(originalAudiences, ", "),
529-
"bound_audience_disregard_trailing_slash": true,
530-
}
531-
532-
req := &logical.Request{
533-
Operation: logical.CreateOperation,
534-
Path: "role/test13",
535-
Storage: storage,
536-
Data: data,
537-
}
538-
539-
resp, err := b.HandleRequest(context.Background(), req)
540-
if err != nil {
541-
t.Fatal(err)
542-
}
543-
if resp != nil && resp.IsError() {
544-
t.Fatalf("did not expect error")
545-
}
546-
547-
role, err := b.(*jwtAuthBackend).role(context.Background(), storage, "test13")
548-
if err != nil {
549-
t.Fatal(err)
550-
}
551-
552-
// compare the expected audiences with the actual result
553-
expectedAudiences := []string{"audience-1", "audience-2", "audience-3"}
554-
if !reflect.DeepEqual(role.BoundAudiences, expectedAudiences) {
555-
t.Fatalf("expected audiences: %v, got: %v", expectedAudiences, role.BoundAudiences)
556-
}
557-
})
558-
559-
t.Run("duplicate audiences are not included", func(t *testing.T) {
560-
b, storage := getBackend(t)
561-
originalAudiences := []string{"audience-1/", "audience-1", "audience-3/"}
562-
563-
data := map[string]interface{}{
564-
"role_type": "jwt",
565-
"user_claim": "user",
566-
"policies": "test",
567-
"bound_audiences": strings.Join(originalAudiences, ", "),
568-
"bound_audience_disregard_trailing_slash": true,
569-
}
570-
571-
req := &logical.Request{
572-
Operation: logical.CreateOperation,
573-
Path: "role/test14",
574-
Storage: storage,
575-
Data: data,
576-
}
577-
578-
resp, err := b.HandleRequest(context.Background(), req)
579-
if err != nil {
580-
t.Fatal(err)
581-
}
582-
if resp != nil && resp.IsError() {
583-
t.Fatalf("did not expect error")
584-
}
585-
586-
role, err := b.(*jwtAuthBackend).role(context.Background(), storage, "test14")
587-
if err != nil {
588-
t.Fatal(err)
589-
}
590-
591-
// compare the expected audiences with the actual result
592-
expectedAudiences := []string{"audience-1", "audience-3"}
593-
if !reflect.DeepEqual(role.BoundAudiences, expectedAudiences) {
594-
t.Fatalf("expected audiences: %v, got: %v", expectedAudiences, role.BoundAudiences)
595-
}
596-
})
597519
}
598520

599521
func TestPath_OIDCCreate(t *testing.T) {

0 commit comments

Comments
 (0)