Skip to content
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

Use electron-store to persist the oauth2 CLIENT_SECRET #1

Open
xrl opened this issue Jan 17, 2025 · 0 comments
Open

Use electron-store to persist the oauth2 CLIENT_SECRET #1

xrl opened this issue Jan 17, 2025 · 0 comments

Comments

@xrl
Copy link
Member

xrl commented Jan 17, 2025

We need a CLIENT_SECRET but we shouldn't store it in the ENV or JSON file. We can use electron-store to write to a file with managed encryption.

Also, to motivate why we don't need the client secret apriori, I asked the Claud AI to diagram an oauth2 flow:

sequenceDiagram
    participant User
    participant Electron App
    participant Backend Server
    participant OAuth Provider

    User->>Electron App: Initiates login
    Note over Electron App: Generates code verifier<br/>and code challenge (PKCE)
    
    Electron App->>OAuth Provider: Authorization request with<br/>code challenge + client_id
    OAuth Provider->>User: Shows login page
    User->>OAuth Provider: Enters credentials
    OAuth Provider->>Electron App: Returns authorization code
    
    Electron App->>Backend Server: Sends auth code + code verifier
    Note over Backend Server: Stores client secret<br/>securely
    Backend Server->>OAuth Provider: Exchanges code + client secret<br/>+ code verifier for tokens
    OAuth Provider->>Backend Server: Returns access/refresh tokens
    Backend Server->>Electron App: Returns tokens
    
    Note over Electron App: Stores tokens securely<br/>in system keychain
    Electron App->>User: Login complete
Loading

so I think we need to figure out the PKCE bit to "do it right"? Or something? Maybe we can send the user to the login page without user the client secret and see what happens?

@xrl xrl changed the title Use keytar to store the oauth2 CLIENT_SECRET Use electron-store to persist the oauth2 CLIENT_SECRET Jan 17, 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

No branches or pull requests

1 participant