-
Notifications
You must be signed in to change notification settings - Fork 295
feat: Adding Expiration Column to API Tokens #2421
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -151,6 +151,7 @@ type AuthToken struct { | |||||
| Key string `json:"key,omitempty"` | ||||||
| HmacMethod string `json:"hmac_method"` | ||||||
| LastAccess time.Time `json:"last_access"` | ||||||
| Expiration null.Time `json:"expires_at"` | ||||||
|
Contributor
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== AuthToken field/tag check =="
rg -n -C2 'type AuthToken struct|Expiration|null.Time|expires_at|gorm:"column:expires_at"' cmd/api/src/model/auth.go
echo
echo "== GORM naming strategy check (repo-wide) =="
rg -n -C3 'gorm\.Config|NamingStrategy|schema\.NamingStrategy|NameReplacer|ColumnName' --type=go cmd/api/src
echo
echo "== Column name references for auth_tokens =="
rg -n -C2 '\bauth_tokens\b|\bexpires_at\b|\bexpiration\b' cmd/api/srcRepository: SpecterOps/BloodHound Length of output: 14522 Add explicit GORM column mapping to prevent mismatch with database schema. At line 154, the Fix- Expiration null.Time `json:"expires_at"`
+ Expiration null.Time `json:"expires_at" gorm:"column:expires_at"`📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
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. The other way to fix this is to use the same name:
Contributor
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.
This approach is cleaner and more consistent with the rest of the codebase. The func (s AuthToken) StripKey() AuthToken {
return AuthToken{
UserID: s.UserID,
ClientID: s.ClientID,
Key: "",
HmacMethod: s.HmacMethod,
LastAccess: s.LastAccess,
Unique: s.Unique,
Name: s.Name,
ExpiresAt: s.ExpiresAt,
}
}✏️ Learnings added
🧠 Learnings used |
||||||
|
|
||||||
| Unique | ||||||
| } | ||||||
|
|
@@ -174,6 +175,7 @@ func (s AuthToken) StripKey() AuthToken { | |||||
| LastAccess: s.LastAccess, | ||||||
| Unique: s.Unique, | ||||||
| Name: s.Name, | ||||||
| Expiration: s.Expiration, | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -185,7 +187,8 @@ func (s AuthTokens) IsSortable(column string) bool { | |||||
| "last_access", | ||||||
| "created_at", | ||||||
| "updated_at", | ||||||
| "deleted_at": | ||||||
| "deleted_at", | ||||||
| "expires_at": | ||||||
| return true | ||||||
| default: | ||||||
| return false | ||||||
|
|
@@ -203,6 +206,7 @@ func (s AuthTokens) ValidFilters() map[string][]FilterOperator { | |||||
| "created_at": {Equals, GreaterThan, GreaterThanOrEquals, LessThan, LessThanOrEquals, NotEquals}, | ||||||
| "updated_at": {Equals, GreaterThan, GreaterThanOrEquals, LessThan, LessThanOrEquals, NotEquals}, | ||||||
| "deleted_at": {Equals, GreaterThan, GreaterThanOrEquals, LessThan, LessThanOrEquals, NotEquals}, | ||||||
| "expires_at": {Equals, GreaterThan, GreaterThanOrEquals, LessThan, LessThanOrEquals, NotEquals}, | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
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.
We want to treat this as a nullable field, but this is not creating it as nullable