Skip to content

Conversation

KCui0327
Copy link
Collaborator

No description provided.

@blobcode blobcode mentioned this pull request Aug 20, 2025
@blobcode
Copy link
Collaborator

draft: looking for some feedback on design; assume things are not final

@blobcode blobcode self-assigned this Aug 20, 2025
@blobcode
Copy link
Collaborator

blobcode commented Aug 20, 2025

@KCui0327 @ambroseling @elwincheng for thoughts

Copy link
Collaborator Author

@KCui0327 KCui0327 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Where is logout functionality?
  2. I find it a little hard to follow the auth flow in code with no clear separation between the OAuth2 and session auth patterns mixed
  • would help to make a diagram showing how the user interacts with the auth system and the control that is going on


import (
"context"
"encoding/json"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import

supervisor := NewSupervisor(redisAddr, consumerID, gpuType)
manager := manage.NewDefaultManager()
manager.SetAuthorizeCodeTokenCfg(manage.DefaultAuthorizeCodeTokenCfg)
manager.MustTokenStorage(store.NewMemoryTokenStore()) // TODO: move to redis?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding currently, if the API gateway crashes and restarts then users will need to get new tokens. Therefore, I would suggest moving to redis

func (a *App) jsonResponse(w http.ResponseWriter, statusCode int, response APIResponse) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(statusCode)
json.NewEncoder(w).Encode(response)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to handle error here


func (a *App) refresh(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, world!\n")
// TODO: move this to a file?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to a file

return id, nil
}

func (a *App) getSession(session_id string) (string, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use camel case

if strings.HasPrefix(authHeader, "Session ") {
return strings.TrimPrefix(authHeader, "Session ")
} else {
if cookie, err := r.Cookie("session"); err == nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing indent

wg sync.WaitGroup
}

func NewApp(redisAddr, gpuType string) *App {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the purpose of gpuType here?

@@ -1,47 +1,87 @@
package main

import (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's decouple some of the logic from this file to other new or existing files

)

// creates a user session in redis
func (a *App) CreateSession(uid string) (string, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to add session expiration and proper session structure right?

@blobcode blobcode mentioned this pull request Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants