Commit 43ea776
authored
[Website] Add support for private github repos via git:directory (#2856)
## Motivation for the change, related issues
Currently, WordPress Playground can only fetch [git:directory
resources](https://wordpress.github.io/wordpress-playground/blueprints/steps/resources/#gitdirectoryreference)
from public Github repositories, private ones are not supported.
Related: #2182.
This PR adds Github OAuth authentication support for private
repositories:
- Load blueprints that reference private GitHub repositories
- Fetch a token via Github OAuth and a user displayed dialog
- Store the credentials (in memory or localStorage in dev mode, as
previously)
**Note:** Because it uses Github OAuth and thus requires a Github user,
this is not intended for demoing plugins that reside in private repos,
rather for developers to run code in Playground that resides in their
own private repositories.
<img width="1308" height="656" alt="Screenshot 2025-11-03 at 06 58 57"
src="https://github.com/user-attachments/assets/a920020e-b4a7-4b4e-90be-c1ed84e6f778"
/>
## Implementation details
### Authentication Flow
- Added token storage and authentication helpers to
git-sparse-checkout.ts
- Git protocol functions now send HTTP Basic Auth headers for Github
URLs
- Throws GitHubAuthenticationError on 401/403 responses
### UI
- New modal prompts users to authenticate when accessing private repos
### Technical Details
- Changed OAuth scope from public_repo to repo
- Full page reload after OAuth to retry blueprint with new token
## Testing Instructions (or ideally a Blueprint)
Test with a private repository:
```
{
"steps": [{
"step": "installPlugin",
"pluginData": {
"resource": "git:directory",
"url": "https://github.com/YOUR-USERNAME/YOUR-PRIVATE-REPO",
"ref": "HEAD"
}
}]
}
```
**Expected:** Modal prompts for GitHub auth → redirects to GitHub →
returns and loads repo successfully without showing modal again.
**Verify:** Public repos still work without auth, token persists in dev
mode (localStorage), no modal persistence issues.1 parent 72e4cfa commit 43ea776
File tree
16 files changed
+664
-61
lines changed- packages/playground
- blueprints/src/lib/v1
- client/src
- storage/src/lib
- website
- src
- components
- github-private-repo-auth-modal
- layout
- github
- github-oauth-guard
- lib/state/redux
16 files changed
+664
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| |||
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
| 150 | + | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
| |||
321 | 327 | | |
322 | 328 | | |
323 | 329 | | |
| 330 | + | |
324 | 331 | | |
325 | 332 | | |
326 | 333 | | |
| |||
514 | 521 | | |
515 | 522 | | |
516 | 523 | | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
517 | 529 | | |
518 | 530 | | |
519 | 531 | | |
| |||
532 | 544 | | |
533 | 545 | | |
534 | 546 | | |
| 547 | + | |
535 | 548 | | |
536 | 549 | | |
537 | 550 | | |
| |||
546 | 559 | | |
547 | 560 | | |
548 | 561 | | |
| 562 | + | |
549 | 563 | | |
550 | 564 | | |
551 | 565 | | |
| |||
Lines changed: 90 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
235 | 324 | | |
236 | 325 | | |
237 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| 161 | + | |
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
165 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
166 | 171 | | |
167 | 172 | | |
168 | 173 | | |
| |||
185 | 190 | | |
186 | 191 | | |
187 | 192 | | |
| 193 | + | |
188 | 194 | | |
189 | 195 | | |
190 | 196 | | |
| |||
556 | 562 | | |
557 | 563 | | |
558 | 564 | | |
559 | | - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
560 | 569 | | |
561 | 570 | | |
562 | 571 | | |
563 | 572 | | |
564 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
565 | 577 | | |
566 | 578 | | |
567 | 579 | | |
| |||
570 | 582 | | |
571 | 583 | | |
572 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
573 | 588 | | |
574 | 589 | | |
575 | 590 | | |
576 | 591 | | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
594 | 606 | | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
602 | 614 | | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
612 | 645 | | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
613 | 655 | | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | 656 | | |
619 | 657 | | |
620 | 658 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
88 | 93 | | |
89 | 94 | | |
90 | 95 | | |
| |||
0 commit comments