Shotgrid Personal Access Token based authentication for backend api endpoints#164
Open
Srijan9211 wants to merge 2 commits into
Conversation
Implement production-ready ShotGrid PAT (username + Legacy Password) authentication so every query runs under the user's own token and ShotGrid enforces native per-user permissions. Backend: - ShotGridAuthClient with connection pooling (LRU, max 200 slots) - MongoDB session store with TTL-indexed collections - AbstractSessionStore ABC for swappable backends - ShotGridCredentials dataclass (SOLID Open/Closed design) - JWT mint/validate/refresh/revoke via PAT login flow - Endpoints: /auth/login, /auth/me, /auth/refresh, /auth/logout - Production hardening: strict JWT_SECRET_KEY, corrupt session cleanup, pool release logging, ProdtrackProviderBase as proper ABC Frontend: - ShotGridAuthContext with mount-time token validation and auto-refresh - ShotGridLoginPage (email + password form) - Default VITE_AUTH_PROVIDER set to shotgrid Removed (out of PAT scope): Redis, Google OAuth, AMI callback, SSO/OAuth2 Closes AcademySoftwareFoundation#55 Signed-off-by: Srijan <srijan9211@gmail.com>
Resolve two leftover conflict markers (AuthContext.tsx, shotgrid.py).
AuthContext — NoopAuthProviderInner storage fix:
- All reads, writes and clears now use sessionStorage consistently;
previously token was read from sessionStorage but written to localStorage
on sign-in and removed from localStorage on sign-out, causing silent
logout on every page reload and sign-out leaving the token in place
- Fix indentation of useState/useEffect blocks broken during merge
ShotGridAuthContext — mount validation overhaul:
- Parse /auth/me 200 response and call persist() so user state is
restored even when USER_KEY is absent (e.g. cleared by another tab)
- Replace inline sessionStorage calls in validation path with clear()
so future changes to clear() apply everywhere automatically
- Remove racing apiHandler.setUser restore effect; validation effect now
handles all cases (200 ok, 401/403, network error, 5xx) in one place
- Add timer cancel inside clear() so auto-refresh stops on logout/401
Backend:
- Add default values to ShotGridCredentials.username and access_token so
sessions stored before these fields were added deserialise safely
instead of raising TypeError and being silently deleted on deploy
- Guard auth_provider is not None before calling get_user_email() in
get_current_user to prevent AttributeError 500 when provider is absent
Closes AcademySoftwareFoundation#55
Signed-off-by: Srijan <srijan9211@gmail.com>
jspada200
reviewed
Jun 5, 2026
| endpoint and refreshed periodically. Used when connecting via | ||
| ``session_token=`` (pool path) rather than login+password. | ||
| refresh_token : ShotGrid refresh token — used to obtain a new access_token. | ||
| password : Legacy Login password — stored because shotgun_api3 requires |
Collaborator
There was a problem hiding this comment.
It is strange the SG needs the password for the legacy flow and we cannot just get a token and use that everywhere. I do see why it is saved here so the user just needs to authenticate once on the FE. That being said it is dangerus to save a password this way and it should be encrypted. I want to bring in @loorthu to help review this and maybe suggest other ways to handling it so we do not need to store the password at all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements ShotGrid PAT (Personal Access Token: https://aps.autodesk.com/blog/understanding-pat-its-benefits-and-how-obtain-pat) based authentication for the DNA backend API. This replaces the previous unauthenticated / Google OAuth flow with a production-ready auth system where users sign in with their ShotGrid username and Legacy Login password.
What changed:
Auth flow:
Cloud ShotGrid requires a Personal Access Token (PAT) bound to the user's account at profile.autodesk.com. On-prem sites work with the actual ShotGrid/LDAP password and no PAT.
Testing
How I Tested
Generate a PAT at Autodesk:
Bind the PAT to your ASWF ShotGrid account:
Set your Legacy Login username and password:
Running Stack and Test: