Allow GitHub deploy with custom url and pat#5195
Open
bmo-at-a9s wants to merge 3 commits intocloudfoundry:developfrom
Open
Allow GitHub deploy with custom url and pat#5195bmo-at-a9s wants to merge 3 commits intocloudfoundry:developfrom
bmo-at-a9s wants to merge 3 commits intocloudfoundry:developfrom
Conversation
…tstream (#172) * pass gh token all the way down to backend properly * camel case access token * implement PR feedback
norman-abramovitz
added a commit
that referenced
this pull request
Apr 13, 2026
Ports upstream PR #5195 (author: Jan-Robin Aumann) to modern Stratos patterns on feature/Angular-21. Before this port, Stratos' "deploy from GitHub" wizard only worked against public repositories on github.com. Customers on GitHub Enterprise or with private github.com repos had no path through the UI. This port adds two optional inputs to step 2 of the deploy wizard: - GitHub Enterprise URL — base URL of a GHE instance (validated) - GitHub Access Token — optional PAT for private repos Backend (clean port of the cfapppush plugin): - types.go — GitSCMSourceInfo gains AccessToken, CloneDetails gains AccessToken. Typo fix: upstream used `AcccessToken` (3 c's); fixed here to `AccessToken` (JSON tag was already correct). - deploy.go — threads AccessToken from the websocket message into CloneDetails and into GetVCS(withAccessToken(...)). - vcs.go — functional-options pattern on GetVCS. Access-token URL rewriting moved into vcsCmd.Create itself (upstream did it at the call site) so it can't be bypassed. GetVCS() also returns a fresh struct per call to avoid concurrent callers racing on a mutated package-level prototype. Frontend — modern Angular patterns: - deploy-application-step2.component.html — two new inputs in the existing form-field pattern (not mat-form-field). The access-token input uses type="password" + autocomplete="off" so browsers won't offer to save it. Error surfaces via Tailwind class, not mat-error. - deploy-application-step2.component.ts — new applyGithubEnterpriseAndToken() helper hooked into the existing valueChanges pipeline via tap(). URL validation uses `new URL(...)` in try/catch. No-op when the active SCM is not GitHub (GitLab path stays untouched). - github-project-exists.directive.ts — renamed helper to getTypeAndEndpointWithAuth(), now expects 3 comma-separated parts (type,endpoint,token). - scm-base.ts, github-scm.ts, scm.service.ts — plumbing to carry HttpOptions with an Authorization header through every GitHub API call (repos, branches, commits, search). - @stratosui/git public_api now re-exports BaseSCM and GitHubSCM so consumers can call setAccessToken/setPublicApi without deep imports. - deploy-application-deployer.ts, deploy-application.types.ts — thread accessToken through the GitSCMSourceInfo envelope so it reaches the jetstream backend. - github-commits-list-config-deploy.service.ts — passes access token through when instantiating the SCM for the commits list. Security notes: the PAT is a user secret of similar sensitivity to the UAA token. It's sent over TLS, never persisted server-side, and used only in-memory during the clone. The embedded-in-URL form (required by git's CLI) means it briefly appears in the git process arguments — visible to anyone with shell access inside the jetstream container. Upstream limitation, documented here for future readers. Co-authored-by: Jan-Robin Aumann <jaumann@anynines.com>
norman-abramovitz
added a commit
that referenced
this pull request
Apr 13, 2026
Covers the two pieces of novel backend logic added in the recent port
batch (PR 5169 + PR 5195).
auth_test.go:
- TestRetrieveToken — success case. Mirrors TestVerifySession's mock
plumbing (setupHTTPTest, sqlmock, InitStratosAuthService) to stub a
signed-session user_id/exp and verify the handler returns an
AuthTokenEnvelope containing the decrypted TokenRecord.
- TestRetrieveTokenNoSessionDate — error path. Omits "exp" from the
session so GetSessionInt64Value fails, and verifies the handler
writes an error envelope (status:"error", data:null) rather than
propagating the error to echo.
vcs.go:
- Extracted the access-token URL rewrite logic from Create() into
vcsCmd.repoWithToken(repo). Create() now delegates to it. Pure
refactor — no behavioural change — done so the rewrite can be
unit-tested without shelling out to a real git binary.
vcs_test.go (new file, six tests):
- TestRepoWithToken_NoTokenReturnsURLUnchanged — no-op when token empty
- TestRepoWithToken_EmbedsTokenAsBasicAuth — PAT injected as
x-access-token basic-auth userinfo
- TestRepoWithToken_InvalidURLReturnsError — malformed URL surfaces
a wrapped parse error
- TestRepoWithToken_SpecialCharactersInTokenEscaped — tokens
containing @, :, / must be percent-encoded so they don't prematurely
terminate the userinfo section. This is the class of bug that would
silently point git at the wrong host.
- TestGetVCS_ReturnsFreshCopyNotPrototype — confirms GetVCS() returns
a copy of the package-level vcsGit prototype rather than the
prototype itself, so concurrent callers can't race on a mutated
accessToken field. Directly exercises the concurrency fix that
deviated from upstream PR #5195's GetVCS implementation.
- TestGetVCS_WithAccessTokenOption — confirms the functional-options
pattern actually applies the token to the returned struct and
preserves the prototype's other fields.
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.
Description
The github deployment flow currently only works with public repositories on github.com
This PR introduces changes that make it possible to optionally supply a Personal Access Token to work with a private repository hosted on github.com or both a PAT and a custom url to enable deployments from github enterprise instances.
How Has This Been Tested?
The tests for the current github flow cover this mostly already.
A staging deployment was used to verify that the additional fields work.
Types of changes
Checklist: