Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(showcase): add conditional rendering for login page #602

Merged
merged 19 commits into from
Nov 7, 2023

Conversation

schultzp2020
Copy link
Member

@schultzp2020 schultzp2020 commented Oct 11, 2023

Description

Please explain the changes you made here.

Which issue(s) does this PR fix

PR acceptance criteria

Please make sure that the following steps are complete:

  • GitHub Actions are completed and successful
  • Unit Tests are updated and passing
  • E2E Tests are updated and passing
  • Documentation is updated if necessary (requirement for new features)
  • Add a screenshot if the change is UX/UI related

How to test changes / Special notes to the reviewer

@schultzp2020 schultzp2020 requested a review from a team as a code owner October 11, 2023 20:33
@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2023

🦋 Changeset detected

Latest commit: 80d6a79

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
app Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Zaperex
Copy link
Member

Zaperex commented Oct 12, 2023

Tried testing it with gitlab and got the following error:
image

It appears we also need to configure the auth provider integrations in the packages/backend/src/plugins/auth file and enable sign-in, to be able to allow users to login via these auth providers. Similar to how we configured the github auth provider integration

https://backstage.io/docs/auth/identity-resolver/

Managed to login with gitlab once I configured the auth provider for gitlab.

    providerFactories: {
      ...defaultAuthProviderFactories,
      gitlab: providers.gitlab.create({
        signIn: {
          async resolver({ result: { fullProfile } }, ctx) {
            const userId = fullProfile.username;
            if (!userId) {
              throw new Error(
                `GitLab user profile does not contain a username`,
              );
            }

            // Creates an entity
            const userEntity = stringifyEntityRef({
              kind: 'User',
              name: userId,
              namespace: DEFAULT_NAMESPACE,
            });

            const { entity } = await ctx.findCatalogUser({
              entityRef: userEntity,
            });

            const ownership = getDefaultOwnershipEntityRefs(entity);

            return ctx.issueToken({
              claims: {
                sub: userEntity,
                ent: ownership,
              },
            });
          },
        },
      }),
...

@schultzp2020
Copy link
Member Author

schultzp2020 commented Oct 13, 2023

Tried testing it with gitlab and got the following error: image

It appears we also need to configure the auth provider integrations in the packages/backend/src/plugins/auth file and enable sign-in, to be able to allow users to login via these auth providers. Similar to how we configured the github auth provider integration

https://backstage.io/docs/auth/identity-resolver/

Managed to login with gitlab once I configured the auth provider for gitlab.

    providerFactories: {
      ...defaultAuthProviderFactories,
      gitlab: providers.gitlab.create({
        signIn: {
          async resolver({ result: { fullProfile } }, ctx) {
            const userId = fullProfile.username;
            if (!userId) {
              throw new Error(
                `GitLab user profile does not contain a username`,
              );
            }

            // Creates an entity
            const userEntity = stringifyEntityRef({
              kind: 'User',
              name: userId,
              namespace: DEFAULT_NAMESPACE,
            });

            const { entity } = await ctx.findCatalogUser({
              entityRef: userEntity,
            });

            const ownership = getDefaultOwnershipEntityRefs(entity);

            return ctx.issueToken({
              claims: {
                sub: userEntity,
                ent: ownership,
              },
            });
          },
        },
      }),
...

@Zaperex this PR does not cover the entity mapping so this is to be expected.

Signed-off-by: Paul Schultz <pschultz@pobox.com>
@gorkem
Copy link
Contributor

gorkem commented Oct 13, 2023

@Zaperex Test this PR together with #588 which brings signIn implementation for some of the providers already.

packages/app/src/api/JanusBackstageCustomizeApiClient.ts Outdated Show resolved Hide resolved
packages/app/src/api/index.ts Outdated Show resolved Hide resolved
packages/app/src/lib/CustomTechRadar.ts Outdated Show resolved Hide resolved
Signed-off-by: Paul Schultz <pschultz@pobox.com>
Signed-off-by: Paul Schultz <pschultz@pobox.com>
@github-actions
Copy link
Contributor

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

@Zaperex Zaperex mentioned this pull request Oct 23, 2023
Signed-off-by: Paul Schultz <pschultz@pobox.com>
@github-actions
Copy link
Contributor

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

@github-actions
Copy link
Contributor

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

@github-actions
Copy link
Contributor

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

@github-actions
Copy link
Contributor

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

@schultzp2020
Copy link
Member Author

Blocked by backstage/backstage#20877

@PatAKnight PatAKnight linked an issue Nov 1, 2023 that may be closed by this pull request
Copy link
Contributor

github-actions bot commented Nov 6, 2023

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

Copy link
Contributor

github-actions bot commented Nov 6, 2023

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

Signed-off-by: Paul Schultz <pschultz@pobox.com>
Copy link

janus-idp bot commented Nov 6, 2023

backstage-showcase Tests on commit aa42a3d finished with errors.
View test log

Copy link
Contributor

github-actions bot commented Nov 6, 2023

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

Copy link
Contributor

github-actions bot commented Nov 7, 2023

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

Signed-off-by: Paul Schultz <pschultz@pobox.com>
Copy link
Contributor

github-actions bot commented Nov 7, 2023

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

Copy link
Contributor

github-actions bot commented Nov 7, 2023

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

Copy link
Member

@PatAKnight PatAKnight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor question but otherwise looks good

- OneLogin - `onelogin`
- SAML - `saml`

- Add the corresponding authentication provider key as the value to `signInPage` in your `app-config`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include something along the lines of 'To disabled the Guest login set auth.environment to production'?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this brings me to the question, what if someone wants to enable guest in production environment? Is that possible?

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgmt

I have a few questions regarding functionality for example, how one enable guest login if the environment is production or what if someone needs multiple auth providers in sign-in page.
But neither of these is blocking.

@schultzp2020
Copy link
Member Author

schultzp2020 commented Nov 7, 2023

lgmt

I have a few questions regarding functionality for example, how one enable guest login if the environment is production or what if someone needs multiple auth providers in sign-in page. But neither of these is blocking.

Yeah I was debating the same thing. My conclusion was that companies typically only have one sign in option, if this is not the case we can easily change this. However, there is an issue where the proxy sign in can only have ONE option. I have also yet to find a case where logging in is not required for a company.

Signed-off-by: Paul Schultz <pschultz@pobox.com>
Copy link
Member

@PatAKnight PatAKnight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

github-actions bot commented Nov 7, 2023

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

Copy link

sonarcloud bot commented Nov 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@schultzp2020 schultzp2020 merged commit 1de46ce into main Nov 7, 2023
5 checks passed
@schultzp2020 schultzp2020 deleted the conditional-login-page branch November 7, 2023 22:23
Copy link
Contributor

github-actions bot commented Nov 7, 2023

The image is available at: quay.io/janus-idp/backstage-showcase:pr-602!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure Additional Auth Providers
6 participants