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

feature(azure devops): support multiple organisations #18213

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

sanderaernouts
Copy link
Contributor

@sanderaernouts sanderaernouts commented Jun 12, 2023

Hey, I just made a Pull Request!

I Added an AzureDevOpsCredentialProvider, similar to the GitHub and AWS integrations, that can return a token based on the provided URL. This PR resolves #10431 by adding support for organisations to the Azure integration config.

The updated Azure integration configuration looks like this:

integrations:
  azure:
  - host: my.devops.server
    credentials:
    - token: my-pat
  - host: dev.azure.com
    credentials:
    - clientId: <id>
      clientSecret: <secret>
      tenantId: <tenant>
      organisations:
      - my-org
      - my-other-org
      - yet-another-org
    - token: my-org-pat
      organisations:
      - my-other-org

The current token and credential fields in the Azure integration config are deprecated in favour of the credentials field

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@sanderaernouts sanderaernouts requested a review from a team as a code owner June 12, 2023 14:48
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented Jun 12, 2023

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/backend-common packages/backend-common patch v0.19.2
@backstage/integration packages/integration minor v1.6.0
@backstage/plugin-catalog-backend-module-azure plugins/catalog-backend-module-azure patch v0.1.19
@backstage/plugin-scaffolder-backend plugins/scaffolder-backend patch v1.16.0

@backstage-goalie
Copy link
Contributor

Thanks for the contribution!
All commits need to be DCO signed before they are reviewed. Please refer to the the DCO section in CONTRIBUTING.md or the DCO status for more info.

Copy link
Collaborator

@awanlin awanlin left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on @sanderaernouts, I do have a question for you about these changes.

In the PR description you have:

integrations:
  azure:
    host: dev.azure.com
    credentials: 
    - organisations:
      - my-org
      token: my-pat 
    - organisations:
      - my-other-org
      token: my-other-pat

Are you saying that you would be removing the ability to have an array of host? If so that's not ideal as it would make it harder to be able to use Azure DevOps Services and Server instances together with Backstage. This is the exact scenario we have right now and is not an uncommon setup

@sanderaernouts
Copy link
Contributor Author

@awanlin, no, I won't be touching that part. I typed the YAML config example from memory and forgot that the Azure integration config is an array of configs. To clarify, I plan to replace the token and credential fields with a single credentials field. This field is an array of token, service principal or managed identity credentials. The credentials will have an optional organisations field where you can specify which Azure DevOps organisation the credential applies.

integrations:
  azure:
    - host: dev.azure.com
      credentials: 
      - organisations:
        - my-org
        token: my-pat 
      - organisations:
        - my-other-org
        token: my-other-pat
    - host: some.devops.server
      credentials: 
      - token: my-pat 

I have updated the PR description 👍

@awanlin
Copy link
Collaborator

awanlin commented Jun 13, 2023

Awesome, thanks for the follow up @sanderaernouts. Another question popup though: why the extra organizations?

Could this:

integrations:
  azure:
    - host: dev.azure.com
      credentials: 
      - organisations:
        - my-org
        token: my-pat 
      - organisations:
        - my-other-org
        token: my-other-pat
    - host: some.devops.server
      credentials: 
      - token: my-pat 

Be something like this instead:

integrations:
  azure:
    - host: dev.azure.com
      credentials: 
        - organization: my-org
          token: my-pat 
        - organization: my-other-org
          token: my-other-pat
    - host: some.devops.server
      credentials:
        - organization: my-org
          token: my-pat

With Azure DevOps Server the concept of Team Collections is more or less the same as Organizations in Azure DevOps Services. I think going this way seeing as we will have a breaking change makes this more consistent

@sanderaernouts
Copy link
Contributor Author

@awanlin I added an array of organizations to support reusing the same service principal or managed identity for multiple organizations. A single service principal or managed identity could be used as long as the same Azure AD tenant backs the Azure DevOps organizations.

However, I'm also okay with organization; you can still duplicate the service principal or managed identity.

@awanlin
Copy link
Collaborator

awanlin commented Jun 13, 2023

You're last comment helped me better understand what you where trying to do with the config, that works for me then 👍

Maybe we update the description with this then:

integrations:
  azure:
    - host: dev.azure.com
      credentials: 
      - organisations:
        - my-org
        - my-org-related
        - my-org-another-related
        token: my-pat 
      - organisations:
        - my-other-org
        token: my-other-pat
    - host: some.devops.server
      credentials: 
      - token: my-pat 

That shows the credential reuse a little better (well it does for me 😉 )

@sanderaernouts
Copy link
Contributor Author

@awanlin I updated the PR description and will use similar examples when updating the docs. I have also added an example for the Azure DevOps server. Meanwhile, I made good progress on the credential provider yesterday, so there already is some stuff to review if you want to.

Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

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

Nice, great to get this added for azure too! 👍

Couple of initial comments. In particular I think it's best if we split out renames of existing systems in a new PR to avoid breaking changes, because I don't think this overall is something that we can ship straight into a main-line release.

packages/backend-common/src/reading/AzureUrlReader.ts Outdated Show resolved Hide resolved
packages/backend-common/src/reading/AzureUrlReader.ts Outdated Show resolved Hide resolved
packages/integration/src/azure/config.ts Outdated Show resolved Hide resolved
packages/integration/src/azure/config.ts Outdated Show resolved Hide resolved
packages/integration/src/azure/config.ts Outdated Show resolved Hide resolved
@sanderaernouts sanderaernouts force-pushed the support-multiple-azdo-orgs branch 2 times, most recently from 73e7730 to 648fde0 Compare June 15, 2023 12:40
@sanderaernouts sanderaernouts requested a review from a team as a code owner June 15, 2023 12:40
@github-actions github-actions bot added area:catalog Related to the Catalog Project Area area:scaffolder Everything and all things related to the scaffolder project area labels Jun 15, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 15, 2023

Uffizzi Preview deployment-33710 was deleted.

@sanderaernouts sanderaernouts force-pushed the support-multiple-azdo-orgs branch 3 times, most recently from a4d494e to 4bb069c Compare June 16, 2023 09:46
@sanderaernouts sanderaernouts force-pushed the support-multiple-azdo-orgs branch 3 times, most recently from 28b9a2c to 8dfffb8 Compare June 19, 2023 08:43
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jun 19, 2023
@sanderaernouts
Copy link
Contributor Author

@awanlin, I updated the docs as well. Should we restrict personal access token (PAT) credentials to zero or one organization in the integration config? For Azure DevOps, the PAT is organization-specific, so filling out more than one organization makes no sense.

@sanderaernouts sanderaernouts force-pushed the support-multiple-azdo-orgs branch 3 times, most recently from 2d31a3b to 51e7558 Compare August 15, 2023 08:36
Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

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

Nice, thank you! 🎉

Just two nits. It would be nice to have some clarity on #18213 (comment) but I don't feel it's a requirement

There are a lot of PRs we want to get into 1.17 😅

.yarn/releases/yarn-3.2.3.cjs Outdated Show resolved Hide resolved
@sanderaernouts
Copy link
Contributor Author

Nice, thank you! 🎉

Just two nits. It would be nice to have some clarity on #18213 (comment) but I don't feel it's a requirement

There are a lot of PRs we want to get into 1.17 😅

@Rugvip, thanks; I know you guys are busy. I'd prefer to have #18213 (comment) fixed resolved before merging.

I can imagine many contributors are pushing for 1.17, but my PR is the most important one to get merged 😜.

Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

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

@awanlin
Copy link
Collaborator

awanlin commented Aug 15, 2023

I'd just like to note my worries about this getting into the release today. I strongly feel that this needs to be included in at least one of the weekly releases.

@Rugvip
Copy link
Member

Rugvip commented Aug 15, 2023

@awanlin will do!

@Rugvip Rugvip added the merge-after-release This is a bit too scary to merge until after the next release label Aug 15, 2023
Signed-off-by: Sander Aernouts <sander.aernouts@gmail.com>
@awanlin
Copy link
Collaborator

awanlin commented Aug 18, 2023

@Rugvip, this is ready to be merged. Also, it would be good to include this in the release notes for 1.18.0, how do we make sure that happens?

@Rugvip
Copy link
Member

Rugvip commented Aug 21, 2023

@awanlin nice! 🎉

It'll be in the release notes, I've added a section to our internal draft of the notes

@Rugvip Rugvip merged commit d626a38 into backstage:master Aug 21, 2023
33 checks passed
@github-actions
Copy link
Contributor

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.18.0 release, scheduled for Tue, 19 Sep 2023.

@awanlin
Copy link
Collaborator

awanlin commented Aug 21, 2023

Thanks @Rugvip, and many, many, many thanks to @sanderaernouts for the work done in this PR! 🚀

@sanderaernouts sanderaernouts deleted the support-multiple-azdo-orgs branch August 22, 2023 07:39
@sanderaernouts
Copy link
Contributor Author

Thanks, @awanlin and @Rugvip, for your time and feedback 🚀 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:catalog Related to the Catalog Project Area area:scaffolder Everything and all things related to the scaffolder project area documentation Improvements or additions to documentation merge-after-release This is a bit too scary to merge until after the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support multiple Azure organization
5 participants