Skip to content

Commit d8536f7

Browse files
committed
chore(auth): Update GitHub and GitLab auth to use secure sign-in resolvers
Signed-off-by: Jessica He <jhe@redhat.com>
1 parent d82cc45 commit d8536f7

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

.ci/pipelines/value_files/values_showcase-auth-providers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ global:
77
disabled: true
88
- package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-org-dynamic
99
disabled: true
10-
- package: oci://quay.io/rh-ee-jhe/catalog-github-org-transformer:v0.1.0!internal-backstage-plugin-catalog-backend-module-github-org-transformer
10+
- package: oci://quay.io/rh-ee-jhe/catalog-github-org-transformer:v0.2.0!internal-backstage-plugin-catalog-backend-module-github-org-transformer
1111
disabled: true
1212
- package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-msgraph-dynamic
1313
disabled: true

e2e-tests/playwright/e2e/auth-providers/github.spec.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ let context: BrowserContext;
88

99
/* SUPORTED RESOLVERS
1010
GITHUB:
11-
[x] usernameMatchingUserEntityName -> (Default)
11+
[x] userIdMatchingUserEntityAnnotation -> (Default >=1.10.x)
12+
[x] usernameMatchingUserEntityName -> (Default <=1.9.x)
1213
[x] emailMatchingUserEntityProfileEmail
1314
[x] emailLocalPartMatchingUserEntityName
1415
*/
@@ -146,6 +147,30 @@ test.describe("Configure Github Provider", async () => {
146147
await context.clearCookies();
147148
});
148149

150+
test("Login with Github usernameMatchingUserEntityName resolver", async () => {
151+
//A github sign-in resolver that looks up the user using their github username as the entity name.
152+
await deployment.setGithubResolver("usernameMatchingUserEntityName", false);
153+
await deployment.updateAllConfigs();
154+
await deployment.restartLocalDeployment();
155+
await page.waitForTimeout(3000);
156+
await deployment.waitForDeploymentReady();
157+
158+
// wait for rhdh first sync and portal to be reachable
159+
await deployment.waitForSynced();
160+
161+
const login = await common.githubLogin(
162+
"rhdhqeauth1",
163+
process.env.AUTH_PROVIDERS_GH_USER_PASSWORD,
164+
process.env.AUTH_PROVIDERS_GH_USER_2FA,
165+
);
166+
expect(login).toBe("Login successful");
167+
168+
await uiHelper.verifyAlertErrorMessage(
169+
NO_USER_FOUND_IN_CATALOG_ERROR_MESSAGE,
170+
);
171+
await context.clearCookies();
172+
});
173+
149174
test("Login with Github emailMatchingUserEntityProfileEmail resolver", async () => {
150175
//A common sign-in resolver that looks up the user using the local part of their email address as the entity name.
151176
await deployment.setGithubResolver(

e2e-tests/playwright/e2e/auth-providers/gitlab.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ import { GitLabHelper } from "../../utils/authentication-providers/gitlab-helper
66
let page: Page;
77
let context: BrowserContext;
88

9+
/* SUPORTED RESOLVERS
10+
GITLAB:
11+
[x] userIdMatchingUserEntityAnnotation -> (Default >=1.10.x)
12+
[x] usernameMatchingUserEntityName -> (Default <=1.9.x)
13+
[x] emailMatchingUserEntityProfileEmail
14+
[x] emailLocalPartMatchingUserEntityName
15+
*/
16+
917
test.describe("Configure GitLab Provider", async () => {
1018
let common: Common;
1119
let uiHelper: UIhelper;

e2e-tests/playwright/utils/authentication-providers/rhdh-deployment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ class RHDHDeployment {
12361236
// Use local path for local development, OCI path for CI/CD
12371237
const transformerPluginPath = this.isRunningLocal
12381238
? "./dynamic-plugins/dist/@internal/backstage-plugin-catalog-backend-module-github-org-transformer-dynamic"
1239-
: "oci://quay.io/rh-ee-jhe/catalog-github-org-transformer:v0.1.0!internal-backstage-plugin-catalog-backend-module-github-org-transformer";
1239+
: "oci://quay.io/rh-ee-jhe/catalog-github-org-transformer:v0.2.0!internal-backstage-plugin-catalog-backend-module-github-org-transformer";
12401240

12411241
this.setDynamicPluginEnabled(transformerPluginPath, true);
12421242

e2e-tests/playwright/utils/authentication-providers/yamls/dynamic-plugins-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins:
55
disabled: true
66
- package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-org-dynamic
77
disabled: true
8-
- package: oci://quay.io/rh-ee-jhe/catalog-github-org-transformer:v0.1.0!internal-backstage-plugin-catalog-backend-module-github-org-transformer
8+
- package: oci://quay.io/rh-ee-jhe/catalog-github-org-transformer:v0.2.0!internal-backstage-plugin-catalog-backend-module-github-org-transformer
99
disabled: true
1010
- package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-msgraph-dynamic
1111
disabled: true

packages/backend/src/modules/authProvidersModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function getAuthProviderFactory(
155155
authenticator: githubAuthenticator,
156156
...applySignInResolvers({
157157
signInResolver:
158-
githubSignInResolvers.usernameMatchingUserEntityName(),
158+
githubSignInResolvers.userIdMatchingUserEntityAnnotation(),
159159
signInResolverFactories: {
160160
...githubSignInResolvers,
161161
...commonSignInResolvers,
@@ -167,7 +167,7 @@ function getAuthProviderFactory(
167167
authenticator: gitlabAuthenticator,
168168
...applySignInResolvers({
169169
signInResolver:
170-
gitlabSignInResolvers.usernameMatchingUserEntityName(),
170+
gitlabSignInResolvers.userIdMatchingUserEntityAnnotation(),
171171
signInResolverFactories: {
172172
...gitlabSignInResolvers,
173173
...commonSignInResolvers,

0 commit comments

Comments
 (0)