Skip to content

Commit 06eab81

Browse files
authored
feat: add github authentication provider (#42)
* feat: add github authentication provider Signed-off-by: Jan Richter <jrichter@redhat.com> * remove integration providers Signed-off-by: Jan Richter <jrichter@redhat.com> * cleanup and upversion Signed-off-by: Jan Richter <jrichter@redhat.com> --------- Signed-off-by: Jan Richter <jrichter@redhat.com>
1 parent 7c34cb8 commit 06eab81

17 files changed

Lines changed: 169 additions & 55 deletions

File tree

docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default defineConfig({
3333
{ text: "Examples", link: "/examples/" },
3434
{ text: "Overlay Testing", link: "/overlay/" },
3535
{
36-
text: "v1.1.12",
36+
text: "v1.1.13",
3737
items: [{ text: "Changelog", link: "/changelog" }],
3838
},
3939
],

docs/api/helpers/login-helper.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ async loginAsGithubUser(): Promise<void>
4646
Login using GitHub OAuth.
4747

4848
**Required environment variables:**
49-
- `GH_USER_NAME`
50-
- `GH_USER_PASSWORD`
51-
- `GH_2FA_SECRET`
49+
- `VAULT_GH_USER_NAME`
50+
- `VAULT_GH_USER_PASSWORD`
51+
- `VAULT_GH_2FA_SECRET`
5252

5353
### `signOut()`
5454

docs/changelog.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.1.13] - Current
6+
7+
### Added
8+
- Support for GitHub authentication provider
9+
10+
### Changed
11+
- `LoginHelper.loginAsGithubUser` now pulls default user credentials from the following vault keys: `VAULT_GH_USER_ID`, `VAULT_GH_USER_PASS`, `VAULT_GH_2FA_SECRET`
12+
- `APIHelper.githubRequest` pulls default user token from vault key `VAULT_GITHUB_USER_TOKEN`
13+
14+
### Environment Variables
15+
- `VAULT_GITHUB_OAUTH_OVERLAYS_APP_ID` - ID for GitHub OAuth application used as auth provider
16+
- `VAULT_GITHUB_OAUTH_OVERLAYS_APP_SECRET`- Client secret for GitHub OAuth application
17+
- `VAULT_GH_USER_ID` - GitHub user name
18+
- `VAULT_GH_USER_PASS` - GitHub user password
19+
- `VAULT_GH_2FA_SECRET` - GitHub user secret for 2 factor authentication
20+
- `VAULT_GITHUB_USER_TOKEN` - Github user token
21+
522
## [1.1.12] - Current
623

724
### Changed

docs/guide/configuration/environment-variables.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ For GitHub integration:
8383

8484
| Variable | Description | Required |
8585
|----------|-------------|----------|
86-
| `GITHUB_TOKEN` | GitHub personal access token | For API/auth |
87-
| `GH_USER_NAME` | GitHub username | For login |
88-
| `GH_USER_PASSWORD` | GitHub password | For login |
89-
| `GH_2FA_SECRET` | 2FA secret for OTP | For login |
86+
| `VAULT_GITHUB_USER_TOKEN` | GitHub personal access token | For API/auth |
87+
| `VAULT_GH_USER_NAME` | GitHub username | For login |
88+
| `VAULT_GH_USER_PASSWORD` | GitHub password | For login |
89+
| `VAULT_GH_2FA_SECRET` | 2FA secret for OTP | For login |
9090

9191
## Custom Variables
9292

docs/guide/deployment/authentication.md

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The package supports modular authentication configuration, allowing you to switc
88
|----------|-------------|----------|
99
| `guest` | Simple guest authentication | Development, simple tests |
1010
| `keycloak` | OIDC via Keycloak | Production-like auth testing |
11+
| `github` | OAuth via GitHub | Testing where github authentication is needed |
1112

1213
## Guest Authentication
1314

@@ -116,6 +117,33 @@ test.beforeAll(async ({ rhdh }) => {
116117
- Production-like testing scenarios
117118
- Testing logout/session flows
118119

120+
121+
## GitHub Authentication
122+
123+
Allows authentication using github OAuth application.
124+
125+
### Configuration
126+
127+
```typescript
128+
await rhdh.configure({ auth: "github" });
129+
await rhdh.deploy();
130+
```
131+
132+
### Logging in to GitHub
133+
134+
GitHub login is available via `LoginHelper`:
135+
136+
```typescript
137+
test.beforeEach(async ({ loginHelper }) => {
138+
await loginHelper.loginAsGithubUser();
139+
});
140+
```
141+
By default, test user credentials will be pulled from the global workspace in vault.
142+
143+
::: warning
144+
GitHub authentication requires 2FA secret for automated logins. This is more complex to set up than guest or Keycloak auth.
145+
:::
146+
119147
## Environment Variables
120148

121149
### Guest Auth
@@ -135,9 +163,22 @@ These are automatically set by `KeycloakHelper.configureForRHDH()`:
135163
| `KEYCLOAK_METADATA_URL` | OIDC discovery URL |
136164
| `KEYCLOAK_LOGIN_REALM` | Login realm name |
137165

166+
### GitHub Auth
167+
168+
Configuring github auth provider will populate the following variables from global workspace in the vault:
169+
170+
| Variable | Description |
171+
|----------|-------------|
172+
| `VAULT_GITHUB_OAUTH_OVERLAYS_APP_ID` | GitHub OAuth application ID |
173+
| `VAULT_GITHUB_OAUTH_OVERLAYS_APP_SECRET` | GitHub OAuth application client secret |
174+
| `VAULT_GH_USER_ID` | GitHub test user |
175+
| `VAULT_GH_USER_PASS` | Password for GitHub test user |
176+
| `VAULT_GH_2FA_SECRET` | Two-factor auth secret for GitHub test user |
177+
| `VAULT_GITHUB_USER_TOKEN` | Token for GitHub test user |
178+
138179
## Configuration Merging
139180

140-
When you set `auth: "guest"` or `auth: "keycloak"`, the package automatically includes auth-specific configurations:
181+
When you set `auth: "guest"`, `auth: "keycloak"`, or `auth: "github"`, the package automatically includes auth-specific configurations:
141182

142183
```
143184
Package configs:
@@ -149,30 +190,16 @@ Package configs:
149190
├── guest/ # Applied when auth: "guest"
150191
│ └── app-config.yaml
151192
└── keycloak/ # Applied when auth: "keycloak"
193+
│ ├── app-config.yaml
194+
│ ├── dynamic-plugins.yaml
195+
│ └── secrets.yaml
196+
└── github/ # Applied when auth: "github"
152197
├── app-config.yaml
153-
├── dynamic-plugins.yaml
154198
└── secrets.yaml
155199
```
156200

157201
Your project configs are merged on top, so you only need to override what's different.
158202

159-
## GitHub Authentication
160-
161-
GitHub authentication is available via `LoginHelper`:
162-
163-
```typescript
164-
// Requires environment variables:
165-
// GH_USER_NAME, GH_USER_PASSWORD, GH_2FA_SECRET
166-
167-
test.beforeEach(async ({ loginHelper }) => {
168-
await loginHelper.loginAsGithubUser();
169-
});
170-
```
171-
172-
::: warning
173-
GitHub authentication requires 2FA secret for automated logins. This is more complex to set up than guest or Keycloak auth.
174-
:::
175-
176203
## Switching Auth Providers
177204

178205
### In Different Test Files
@@ -189,6 +216,12 @@ test.beforeAll(async ({ rhdh }) => {
189216
await rhdh.configure({ auth: "keycloak" });
190217
await rhdh.deploy();
191218
});
219+
220+
// github-tests.spec.ts
221+
test.beforeAll(async ({ rhdh }) => {
222+
await rhdh.configure({ auth: "github" });
223+
await rhdh.deploy();
224+
});
192225
```
193226

194227
### In Different Projects
@@ -205,6 +238,10 @@ export default defineConfig({
205238
name: "keycloak-tests",
206239
testMatch: "**/keycloak-*.spec.ts",
207240
},
241+
{
242+
name: "github-tests",
243+
testMatch: "**/github-*.spec.ts",
244+
},
208245
],
209246
});
210247
```
@@ -215,6 +252,7 @@ Each project gets its own namespace and deployment with different auth.
215252

216253
1. **Use guest auth for speed** - Faster to set up and run
217254
2. **Use Keycloak for RBAC testing** - When you need user roles
218-
3. **Create test users per test suite** - Avoid shared state
219-
4. **Clean up custom users** - Remove users created during tests
220-
5. **Use environment variables** - Don't hardcode credentials
255+
3. **Use GitHub for tests that connect to Github** - When you need authentication to GitHub
256+
4. **Create test users per test suite** - Avoid shared state
257+
5. **Clean up custom users** - Remove users created during tests
258+
6. **Use environment variables** - Don't hardcode credentials

docs/guide/helpers/login-helper.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ await loginHelper.loginAsGithubUser();
6262
```
6363

6464
Required environment variables:
65-
- `GH_USER_NAME` - GitHub username
66-
- `GH_USER_PASSWORD` - GitHub password
67-
- `GH_2FA_SECRET` - GitHub 2FA secret (for OTP generation)
65+
- `VAULT_GH_USER_NAME` - GitHub username
66+
- `VAULT_GH_USER_PASSWORD` - GitHub password
67+
- `VAULT_GH_2FA_SECRET` - GitHub 2FA secret (for OTP generation)
6868

6969
::: warning
7070
GitHub login requires 2FA secret for automated OTP generation. This is more complex to set up.
@@ -192,9 +192,9 @@ test("login flow", async ({ page, loginHelper }) => {
192192

193193
| Variable | Description | Required |
194194
|----------|-------------|----------|
195-
| `GH_USER_NAME` | GitHub username | Yes |
196-
| `GH_USER_PASSWORD` | GitHub password | Yes |
197-
| `GH_2FA_SECRET` | 2FA secret for OTP | Yes |
195+
| `VAULT_GH_USER_NAME` | GitHub username | Yes |
196+
| `VAULT_GH_USER_PASSWORD` | GitHub password | Yes |
197+
| `VAULT_GH_2FA_SECRET` | 2FA secret for OTP | Yes |
198198

199199
## Troubleshooting
200200

docs/overlay/examples/basic-plugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ workspaces/<plugin>/e2e-tests/
6868
"eslint-plugin-check-file": "^3.3.1",
6969
"eslint-plugin-playwright": "^2.4.0",
7070
"prettier": "^3.7.4",
71-
"@red-hat-developer-hub/e2e-test-utils": "1.1.12",
71+
"@red-hat-developer-hub/e2e-test-utils": "1.1.13",
7272
"typescript": "^5.9.3",
7373
"typescript-eslint": "^8.50.0"
7474
}

docs/overlay/examples/tech-radar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ workspaces/tech-radar/e2e-tests/
7171
"eslint-plugin-check-file": "^3.3.1",
7272
"eslint-plugin-playwright": "^2.4.0",
7373
"prettier": "^3.7.4",
74-
"@red-hat-developer-hub/e2e-test-utils": "1.1.12",
74+
"@red-hat-developer-hub/e2e-test-utils": "1.1.13",
7575
"typescript": "^5.9.3",
7676
"typescript-eslint": "^8.50.0"
7777
}

docs/overlay/test-structure/directory-layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Defines the test package with dependencies and scripts:
6868
"eslint-plugin-check-file": "^3.3.1",
6969
"eslint-plugin-playwright": "^2.4.0",
7070
"prettier": "^3.7.4",
71-
"@red-hat-developer-hub/e2e-test-utils": "1.1.12",
71+
"@red-hat-developer-hub/e2e-test-utils": "1.1.13",
7272
"typescript": "^5.9.3",
7373
"typescript-eslint": "^8.50.0"
7474
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@red-hat-developer-hub/e2e-test-utils",
3-
"version": "1.1.12",
3+
"version": "1.1.13",
44
"description": "Test utilities for RHDH E2E tests",
55
"license": "Apache-2.0",
66
"repository": {

0 commit comments

Comments
 (0)