Skip to content

feat: session-wide GitHub Personal Access Token#7

Closed
matejvasek wants to merge 18 commits into
masterfrom
004-feat-session-wide-gh-pat
Closed

feat: session-wide GitHub Personal Access Token#7
matejvasek wants to merge 18 commits into
masterfrom
004-feat-session-wide-gh-pat

Conversation

@matejvasek
Copy link
Copy Markdown
Collaborator

Summary

  • Replace build-time compiled GitHub PAT (webpack DefinePlugin) with a runtime session-wide PAT prompted via modal dialog
  • PAT is stored in sessionStorage (survives refresh, cleared on tab close) and validated against the GitHub API (GET /user) before being accepted
  • The non-dismissable PatModal gates both the Functions List and Function Create pages — users cannot proceed without a valid PAT
  • Remove the PAT text field from the Create Function form (PAT is now session-wide)
  • Remove __GITHUB_PAT__ from webpack config and delete src/globals.d.ts
  • Skip the login step for OCP internal registry in the generated GitHub Actions workflow (drive by fix, unrelated to main feature)

Changes

Area What changed
src/hooks/usePat.ts New hook backed by sessionStorage (func-console-gh-pat key)
src/components/PatModal.tsx New PF6 modal — validates PAT via Octokit, non-dismissable
src/services/source-control/useSourceControl.ts Accepts pat parameter instead of reading build-time global
src/views/FunctionsListPage.tsx Integrates usePat() + PatModal gate
src/views/FunctionCreatePage.tsx Integrates usePat() + PatModal gate
src/components/CreateFunctionForm.tsx PAT field removed
webpack.config.ts DefinePlugin / __GITHUB_PAT__ removed
backend/main.go Skip login step for OCP internal registry

Test plan

  • yarn test — 46 tests across 11 suites, all passing
  • Open /functions without a PAT in sessionStorage → modal appears, no close button
  • Enter an invalid PAT → error alert shown, modal stays open
  • Enter a valid PAT → modal closes, function list loads
  • Refresh the page → PAT persists, no modal
  • Navigate to /functions/create → no PAT prompt (already set)
  • Open a new tab → PAT is available (same session)
  • Close and reopen browser → PAT is gone, modal reappears

🤖 Generated with Claude Code

matejvasek and others added 18 commits April 13, 2026 13:24
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
When generating GH WF and we using internal OCP registry we do not employ
the docker login step since the func CLI gets the credentials from
kubeconfig. The password/token for the internal registry is the same as
for the OCP cluster.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This is for local debuggins since the /functions URI is already taken by
another plugin on my cluster.

This should be latter reverten when creating final PR.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers replacing build-time webpack DefinePlugin PAT injection with
runtime sessionStorage-backed PAT entry via modal dialog.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Provides pat/setPat/clearPat backed by sessionStorage
under the key 'func-console-gh-pat'. This is the
foundational storage layer for the session-wide GitHub
PAT feature — all other tasks in the plan depend on it.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Modal prompts for a GitHub Personal Access Token and
validates it via Octokit before calling onSave. Uses
PatternFly 6 composable Modal with ModalHeader,
ModalBody, and ModalFooter sub-components.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…e global

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…parameter

- Temporarily pass empty string as PAT (placeholder for Task 4 integration)
- Update test mock to match new useSourceControl signature with pat parameter
- All tests pass

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Wire up usePat hook and PatModal gate in FunctionsListPage.
When no PAT is stored in session storage, PatModal opens to
prompt the user. The PAT is passed through to useSourceControl
so GitHub API calls are authenticated. When PAT is empty, the
effect skips loading repos and marks loaded immediately.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
The PAT is now managed via the session-wide usePat() hook. The form no longer
needs its own PAT input field. The component now collects only the core function
creation parameters, while PAT will be injected at the page level via usePat().

- Remove pat field from CreateFunctionFormData interface
- Remove pat state variable from component
- Remove pat from validation logic
- Remove pat from handleSubmit data object
- Remove PAT FormGroup JSX from the form
- Update tests to reflect new form structure

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… globals

Remove the DefinePlugin entry that was injecting __GITHUB_PAT__ at build time and
delete the globals.d.ts declaration file. Runtime PAT is now obtained via usePat()
hook throughout the application.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Mark feature as passing in features.json, move plan to completed.
Move plan form active to completed.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move back for debugging/development configuration.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
@twoGiants twoGiants self-assigned this Apr 15, 2026
@matejvasek
Copy link
Copy Markdown
Collaborator Author

superseded by
#13
or
#14

@matejvasek matejvasek closed this Apr 23, 2026
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