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

Npm/auth access #757

Merged
merged 11 commits into from
May 6, 2024
Merged

Npm/auth access #757

merged 11 commits into from
May 6, 2024

Conversation

hilmarf
Copy link
Member

@hilmarf hilmarf commented May 2, 2024

Description

When credentials are configured, let's also use them for the read access.

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🎇 Restructuring
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help
  • Separate ticket for tests # (issue/pr)

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Added to documentation?

  • 📜 README.md
  • 🙅 no documentation needed

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

hilmarf added 2 commits May 2, 2024 11:00
moved login and token retrieval to credentials.npm
@hilmarf hilmarf added this to the 2024-Q2 milestone May 2, 2024
@github-actions github-actions bot added the size/m Medium label May 2, 2024
@hilmarf hilmarf linked an issue May 2, 2024 that may be closed by this pull request
Copy link
Contributor

github-actions bot commented May 2, 2024

Mend Scan Summary: ❌

Repository: open-component-model/ocm

VIOLATION DESCRIPTION NUMBER OF VIOLATIONS
HIGH/CRITICAL SECURITY VULNERABILITIES 1
MAJOR UPDATES AVAILABLE 0
LICENSE REQUIRES REVIEW 4
HIGH RISK LICENSES 9
RESTRICTIED LICENSE FOR ON-PREMISE DELIVERY 0

Detailed Logs: mend-scan-> Generate Report
Mend UI

Copy link
Contributor

ocmbot bot commented May 2, 2024

Integration Tests for 2d1f934 run with result: Success ✅!

@hilmarf hilmarf marked this pull request as ready for review May 2, 2024 09:17
@hilmarf hilmarf requested review from mandelsoft and fabianburth May 2, 2024 09:17
@hilmarf hilmarf marked this pull request as draft May 2, 2024 09:27
@hilmarf hilmarf marked this pull request as ready for review May 2, 2024 10:28
Copy link
Contributor

ocmbot bot commented May 2, 2024

Integration Tests for 2d1f934 run with result: Success ✅!

@hilmarf hilmarf enabled auto-merge (squash) May 2, 2024 13:06
Copy link
Contributor

ocmbot bot commented May 2, 2024

Integration Tests for 0b2baf5 run with result: Success ✅!

Copy link
Contributor

ocmbot bot commented May 2, 2024

Integration Tests for 53f3617 run with result: Success ✅!


// BearerToken retrieves the bearer token for the given repository URL and package name.
// Either it's setup in the credentials or it will login to the registry and retrieve it.
func BearerToken(ctx cpi.ContextProvider, repoUrl string, pkgName string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Those functions are typically in a technology support package (like pkg/helm). The identity packages are typically just used to describe the technology specific identity mapping for the uniform credential handling mechanism, so they deal with the identity and credential attributes and identity matchers used for the credential mechanism to find and describe credential sets. If you want to put technology specific access code into this identity package you should at least use different file names, not the standard names used for the mapping in the other packages to keep some kind of consistency. Better would be to put technology specific access code into a separate package to be used by access methods, blob access and uploader packages.

Basically all identity packages have some GetCredentials function taking the used identity parameters and providing found credential properties in a standard way. This method is then used in the technology support package to do technology specific things like you did in this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -96,11 +94,11 @@ func (a *AccessSpec) GetInexpensiveContentVersionIdentity(access accspeccpi.Comp
}

func (a *AccessSpec) getPackageMeta(ctx accspeccpi.Context) (*meta, error) {
url := a.Registry + path.Join("/", a.Package, a.Version)
Copy link
Contributor

Choose a reason for hiding this comment

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

you moved this code in this method to change the reader method, but copied it into the reader method, also.

I think, this is, because you need parts of the attributes incorporated into the url as dedicated fields.
May be you should then add a method on the AccessSpec to calculate the URL to avoid the code duplication.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@hilmarf hilmarf requested a review from mandelsoft May 3, 2024 09:05

// BearerToken retrieves the bearer token for the given repository URL and package name.
// Either it's setup in the credentials or it will login to the registry and retrieve it.
func BearerToken(ctx cpi.ContextProvider, repoUrl string, pkgName string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think to stay uniform with the existing packages, we should also move BearerToken() and Authorize() to the npm login file.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@morri-son morri-son requested a review from fabianburth May 6, 2024 07:31
Copy link
Contributor

ocmbot bot commented May 6, 2024

Integration Tests for 43431bb run with result: Success ✅!

Copy link
Contributor

ocmbot bot commented May 6, 2024

Integration Tests for 43431bb run with result: Success ✅!

Copy link
Contributor

ocmbot bot commented May 6, 2024

Integration Tests for 975a485 run with result: Success ✅!

@hilmarf hilmarf merged commit 4473dac into main May 6, 2024
15 checks passed
@hilmarf hilmarf deleted the npm/auth_access branch May 6, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/m Medium
Projects
Status: 🔒Closed
Development

Successfully merging this pull request may close these issues.

Credentials for npm repositories have no effect
3 participants