-
Notifications
You must be signed in to change notification settings - Fork 263
fix: correct jwt nbf handling and scope flag parsing #2049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,9 +81,9 @@ func authJWTCmd() *cobra.Command { | |||||||||||||||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| exp = time.Unix(nbfInt, 0) | ||||||||||||||||||||||||||||||||||||||||||
| nbf = time.Unix(nbfInt, 0) | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| exp = now.Add(dur) | ||||||||||||||||||||||||||||||||||||||||||
| nbf = now.Add(dur) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -100,12 +100,12 @@ func authJWTCmd() *cobra.Command { | |||||||||||||||||||||||||||||||||||||||||
| var scope ajwt.PermissionScopes | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if cmd.Flags().Changed(FlagJWTScope) { | ||||||||||||||||||||||||||||||||||||||||||
| scopeString, err := cmd.Flags().GetString(FlagJWTAccess) | ||||||||||||||||||||||||||||||||||||||||||
| scopeStrings, err := cmd.Flags().GetStringSlice(FlagJWTScope) | ||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if err = scope.UnmarshalCSV(scopeString); err != nil { | ||||||||||||||||||||||||||||||||||||||||||
| if err = scope.UnmarshalCSV(strings.Join(scopeStrings, ",")); err != nil { | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
102
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reject This block still accepts Suggested guard if cmd.Flags().Changed(FlagJWTScope) {
+ if access != ajwt.AccessTypeScoped {
+ return fmt.Errorf("`scope` can only be set when `access=scoped`")
+ }
+
scopeStrings, err := cmd.Flags().GetStringSlice(FlagJWTScope)
if err != nil {
return err
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flip the
nbf/expvalidation predicate.These assignments are correct, but Line 117 still uses
!nbf.After(exp), so the command rejects the valid case wherenbf < exp. With the defaultnbf=nowand any futureexp,auth jwterrors out.🤖 Prompt for AI Agents