-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Add OAuth2 authentication flow for Coder #151
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
plugins/backstage-plugin-coder/src/components/CoderAuthForm/CoderAuthInputForm.tsx
Outdated
Show resolved
Hide resolved
plugins/backstage-plugin-coder/src/components/CoderProvider/CoderAppConfigProvider.tsx
Outdated
Show resolved
Hide resolved
plugins/backstage-plugin-coder/src/components/CoderProvider/CoderAuthProvider.tsx
Outdated
Show resolved
Hide resolved
c46c81d
to
cc948e0
Compare
accessUrl: 'https://dev.coder.com', | ||
}, | ||
|
||
oauth: { | ||
clientId: '09cd00cf-9517-401c-9601-3712f187b53c', | ||
backendUrl: 'http://localhost:7007', | ||
}, |
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.
I've been having trouble piping config from appConfig data into the frontend apps, so this is still hard coded to get things working for now.
oauth: { | ||
clientId: '09cd00cf-9517-401c-9601-3712f187b53c', | ||
backendUrl: 'http://localhost:7007', | ||
}, |
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.
Same appConfig issue here
coder: | ||
deployment: | ||
accessUrl: https://dev.coder.com | ||
oauth: | ||
clientId: ${CODER_OAUTH_CLIENT_ID:-backstage} | ||
clientSecret: ${CODER_OAUTH_CLIENT_SECRET:-change-me} |
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.
Not sure if this should be here or somewhere else, but is useful for development.
aa81e22
to
1c4b44d
Compare
Added OAuth2 sign-in capability to the Coder Backstage plugin, allowing users to authenticate via Coder's OAuth2 provider instead of manually entering tokens. Frontend changes: - Added 'Sign in with Coder' OAuth2 button to CoderAuthInputForm - OAuth button opens popup window for better UX - PostMessage-based token exchange between popup and parent window - Configurable via appConfig.oauth.clientId and appConfig.oauth.backendUrl - Falls back to manual token entry if needed Backend changes: - Created new backend plugin (@coder/backstage-plugin-coder-backend) - Handles OAuth2 callback at /api/auth/coder/oauth/callback - Exchanges authorization codes for access tokens - Returns tokens to frontend via postMessage - Configurable OAuth credentials via app-config (coder.oauth.*) Key features: - Clean separation between frontend and backend concerns - Secure token exchange with configurable backend URL validation - Maintains existing manual token entry as fallback option
|
||
coder: | ||
deployment: | ||
accessUrl: https://dev.coder.com |
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.
Maybe unused
export interface Config { | ||
/** | ||
* @visibility frontend | ||
*/ | ||
coder: { | ||
/** | ||
* @deepVisibility frontend | ||
*/ | ||
deployment: { | ||
accessUrl: string; | ||
}; | ||
|
||
/** | ||
* @visibility frontend | ||
*/ | ||
oauth: { | ||
/** | ||
* @visibility frontend | ||
*/ | ||
clientId: string; | ||
|
||
/** | ||
* @visibility secret | ||
*/ | ||
clientSecret: string; | ||
}; | ||
}; | ||
} |
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.
Very cool I had no clue how to do this lol
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.
Approving so this can get merged in. We tested out a few different flows, and while the backend doesn't have any tests yet, we do still feel reasonably sure that things work
Added OAuth2 sign-in button to CoderAuthInputForm allowing users to
authenticate via Coder's OAuth2 provider instead of manually entering tokens.
Created new backend plugin (@coder/backstage-plugin-coder-backend) to handle
OAuth2 callback flow, exchange authorization codes for access tokens, and
securely communicate tokens back to the frontend via postMessage.
Screen.Recording.2025-10-12.at.5.17.55.PM.mov