- 
                Notifications
    You must be signed in to change notification settings 
- Fork 180
Remove access tokens from entgo #1357
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
Conversation
ce1250e    to
    267b66c      
    Compare
  
    9d75dd9    to
    af512a3      
    Compare
  
    | @@ -0,0 +1,6 @@ | |||
| -- name: ValidateEnvBuilds :one | |||
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.
If we're not using the results, we might be able to swap this for :exec and just check for an error.
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.
It wouldn't return an error
| func ValidateAccessToken(ctx context.Context, db *client.Client, accessToken string) bool { | ||
| hashedToken, err := keys.VerifyKey(keys.AccessTokenPrefix, accessToken) | ||
| if err != nil { | ||
| return false | ||
| } | ||
|  | ||
| exists, err := db.AccessToken.Query().Where(accesstoken.AccessTokenHash(hashedToken)).Exist(ctx) | ||
| _, err = db.GetUserIDFromAccessToken(ctx, hashedToken) | ||
| if err != nil { | ||
| log.Printf("Error while checking access token: %s\n", err.Error()) | ||
|  | ||
| return false | ||
| } | ||
|  | ||
| return exists | ||
| return true | ||
| } | 
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.
It'd be easy to get some tests around this, via testcontainers
Note
Replaces ent-based AccessToken with sqlc-backed queries and clients, updates reverse proxy and seeding to use them, adds DB-backed validation and tests.
queries/builds/validate_build.sqland generatedExistsWaitingTemplateBuildfor access validation viaaccess_tokens.client.TestsRawSQL,testutilswith Testcontainers + migrations.sqlc.yaml(glob queries, type overrides).packages/db/client(sqlc) for access token validation and template access checks.Validatepath usesExistsWaitingTemplateBuild;ValidateAccessTokenusesGetUserIDFromAccessToken.handlers.NewStorenow acceptscontext.Contextand builds sqlc client; wiring updated.Validatecovering token/env/status cases.Userschema and generated code accordingly.Written by Cursor Bugbot for commit bd3bf35. This will update automatically on new commits. Configure here.