Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@mest-fe/nestjs-sso
Advanced tools
Common authentication SDK for internal services (NestJS project).
yarn add @mest-fe/nestjs-sso
SSOModule.forRoot()
to your module imports.Add a decorator to any controller class or method, and the user will be authenticated before the method is called.
// controller
@MestAuth()
@Controller('/users')
export class UsersController {
}
// method
@MestAuth()
@Post('/login')
async login() {
return 'ok'
}
Specify roles for controller classes or methods:
// Require authenticated and admin role
@MestRoleAuth(MestRoles.ADMIN)
@Delete('/users')
async removeUsers() {
return 'ok'
}
On any controller method, the user of the current session can be injected:
@Get('/users/self')
@MestAuth()
async getSelf(@MestUser() user: MestUserType){
return user
}
When you just need to authenticate a fixed token, i.e. string comparison, use bearer authentication mode:
// module
HttpBearerModule.forRoot({ token: 'my-token' })
// controller
@Get('/token')
@MestTokenAuth()
async getMessage() {
return `hello world`
}
// fetch('...', { headers: { Authorization: 'Bearer my-token' }}>
When a user without a session request an api that requires authentication, a 401
error will be returned in http;
If the user simply has a role that does not match, a 403
error will be thrown.
The server will not handle these errors and you should direct the user on the client side to the sso.mest.sh to log in.
FAQs
Common authentication SDK for internal services (NestJS project).
The npm package @mest-fe/nestjs-sso receives a total of 10 weekly downloads. As such, @mest-fe/nestjs-sso popularity was classified as not popular.
We found that @mest-fe/nestjs-sso demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.