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

Add @loopback/security #3551

Merged
merged 3 commits into from
Aug 20, 2019
Merged

Add @loopback/security #3551

merged 3 commits into from
Aug 20, 2019

Conversation

jannyHou
Copy link
Contributor

@jannyHou jannyHou commented Aug 15, 2019

Implements #2900
cherry-picked from #2902

Create a shared layer for @loopback/authentication and @loopback/authorization, which defines the security information(context) and binding keys for Subject and its members.

For reviewers:

This PR is migrated from draft #2902.
It contains a comprehensive design of the security system (now@loopback/authentication and @loopback/authorization only share interface UserProfile)

So we have different plans for implementing the security module:

  • Plan 1:
    • If we agree on the design, let's improve and land this PR, then release it
  • Plan 2:
    • If it takes time to discuss and agree on the comprehensive design, I can only include interface Principle and UserProfile(which extends Principle) in this PR.
    • Then incrementally add other pieces in other PRs
  • Plan 3:
    • If we couldn't agree on interface Principle, let's at least extract the existing UserProfile interface here as the first release.

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@jannyHou jannyHou self-assigned this Aug 15, 2019
@jannyHou jannyHou changed the title Add @loopback/security [WIP]Add @loopback/security Aug 15, 2019
@jannyHou jannyHou changed the title [WIP]Add @loopback/security Add @loopback/security Aug 15, 2019
@dhmlau
Copy link
Member

dhmlau commented Aug 16, 2019

@jannyHou, for the decreased in code coverage, is there something we can do about it? Thanks.

@raymondfeng
Copy link
Contributor

subject.addUser(user);
expect(subject.user).to.eql(user);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add tests for addApplication and addCredential etc.

@jannyHou
Copy link
Contributor Author

@dhmlau @raymondfeng Tests added :)

"src/**/*.ts"
],
"codeSectionDepth": 4
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This file should be removed as we no longer use strong-docs.

"build": "lb-tsc",
"clean": "lb-clean loopback-authorization*.tgz dist package *.tsbuildinfo",
"integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"",
"prepublishOnly": "npm run build && npm run build:apidocs",
Copy link
Contributor

Choose a reason for hiding this comment

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

This line should be removed.

"scripts": {
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
"build": "lb-tsc",
"clean": "lb-clean loopback-authorization*.tgz dist package *.tsbuildinfo",
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be:

"clean": "lb-clean loopback-security*.tgz dist package *.tsbuildinfo",

"@loopback/build": "^1.5.2",
"@loopback/testlab": "^1.2.7",
"@types/debug": "^4.1.4",
"@types/node": "10.14.15",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be a range?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch 👍

],
"repository": {
"type": "git",
"url": "https://github.com/strongloop/loopback-next.git"
Copy link
Contributor

Choose a reason for hiding this comment

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

Add "directory": "packages/security"

"type": "git",
"url": "https://github.com/strongloop/loopback-next.git"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's compare with an existing module such as @loopback/context to make sure the package.json is consistent.

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

Successfully merging this pull request may close these issues.

3 participants