![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@saascannon/auth
Advanced tools
Node.js Library for authorizing requests to your apis using Saascannon credentials
This package provides utility functions for verifying user authentication status and permissions guards for saascannon credentials.
npm i @saascannon/auth
import { SaascannonAuth } from "@saascannon/auth";
const scAuth = new SaascannonAuth("https://your-tenant.region.saascannon.app");
// Verify credentials
const userAccessTokenDetails = scAuth.verifyUserToken("user-bearer-token");
// Verify permissions ('posts:publish' OR 'admin')
const userCanPublishPosts = userAccessTokenDetails.hasPermissionTo([
["posts:publish"],
["admin"],
]);
If you are using express, you can use some pre-built wrappers for implementing saascannon auth into your service easily.
import { SaascannonAuth } from "@saascannon/auth";
import { expressAuthGuard, Request } from "@saascannon/auth/express";
import express, { Response, NextFunction } from "express";
const scAuth = new SaascannonAuth("https://your-tenant.region.saascannon.app");
const app = express();
const { verifyUserCredential, verifyUserPermissions } = expressAuthGuard({
requestUserKey: "user", // userAccessTokenDetails will be stored in the 'user' key of the request object
});
// Ensure users are authenticated for all routes
app.use(verifyUserCredential(scAuth));
// Route with permissions middleware
app.post(
"/posts",
verifyUserPermissions([["posts:publish"], ["admin"]]),
(req: Request, res: Response) => {
if (
req.body.restrictedField &&
// You can also check permissions within the route
!req.user.hasPermissionTo("posts:publish-with-rf")
) {
return res.sendStatus(403);
}
publishPost(req.body);
return res.sendStatus(201);
},
);
// Handle Errors
app.use((err: any, req: Request, res: Response, next: NextFunction) => {
// User is not authenticated
if (err.code === "unauthenticated") {
return res.sendStatus(401);
}
// Insufficient permissions
if (err.code === "unauthorized") {
return res.sendStatus(403);
}
res.sendStatus(500);
});
FAQs
Node.js Library for authorizing requests to your apis using Saascannon credentials
We found that @saascannon/auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.