Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Orion allows you to build a REST API app in just a few lines of code. This library is to be used in combination with Node and Express. It sets up all the necessary CRUD data endpoints, file uploads, authentication endpoints, and error handling.
The latest version of the library supports the following components:
In this documentation:
$ npm install --save express
$ npm install --save orion-api
$ node node_modules/orion-api/setup.js ./config.js ./setup.sql
The above command will create a SQL server query file named setup.sql that you can run on the
database server to set up the tables.var express = require('express');
var orion = require('orion-api');
var config = require('./config');
var app = new express();
orion.setConfig(config);
orion.setupApiEndpoints(app);
orion.startApiApp(app);
$ node server.js
A configuration module is required to give the application the necessary information about your project. This module should specify the connection strings, authentication and authorization settings, user roles and access levels, and most importantly, the data models.
Below is the structure of a configuration module, with description for each property.
module.exports =
{
// (Required) Secret key string for authentication purposes.
secretKey: __SECRETKEY__,
// (Required) Salt string for encrypting passwords.
salt: __SALT__,
// (Required) Database connection string.
databaseConnectionString: __DB_CONNECTION_STRING__,
// (Optional) Azure Blob Storage connection string. Required if you want to support
// file upload. Set to null if not applicable.
storageConnectionString: __STORAGE_CONNECTION_STRING__,
// (Optional) Azure Blob Storage account name. Required if you want to support
// file upload. Set to null if not applicable.
storageContainerName: __STORAGE_CONTAINER_NAME__,
// (Optional) Azure Application Insights key. Required if you want to support
// monitoring. Set to null if not applicable.
appInsightsKey: __APPLICATION_INSIGHTS_KEY__,
// (Optional) Facebook app secret. Required if you want to support Facebook
// authentication. Set to null if not applicable.
facebookAppSecret: __FACEBOOK_APP_SECRET__,
// (Optional) Facebook app ID. Required if you want to support Facebook
// authentication. Set to null if not applicable.
facebookAppId: __FACEBOOK_APP_ID__,
// (Required) Requirements for new user passwords
passwordReqs:
{
// (Required) Minimum character length
minLength: 8,
// (Required) Whether or not the password should have an uppercase character.
uppercaseChar: false,
// (Required) Whether or not the password should have an lowercase character.
lowercaseChar: false,
// (Required) Whether or not the password should have a digit character.
digitChar: false,
// (Required) Whether or not the password should have a special character.
specialChar: false
},
// (Required) Array of user roles.
// "guest" and "owner" are special user roles that don't need to be included in this list.
// "guest" role is given to an unauthenticated user, and "owner" role is given to an
// authenticated user who is requesting a resource that they own.
roles: ["member", "admin"],
// (Required) Default role assigned to authenticated user after signing up.
defaultRole: "member",
// (Required) List of data entities/tables
entities:
{
"asset":
{
fields:
{
"id": { type: "id", isEditable: false, createReq: 0, foreignKey: null },
"ownerid": { type: "int", isEditable: false, createReq: 0, foreignKey: { foreignEntity: "user", resolvedKeyName: "owner" }},
"filename": { type: "string", isEditable: true, createReq: 2, foreignKey: null }
},
readConditionStrings: [{ roles: ["owner", "admin"], fn: function(u) { return ""; } }],
validators:
{
create: [{ roles: ["member"], fn: function(n) { return true; } }],
update: [],
delete: [{ roles: ["owner", "admin"], fn: function(o) { return true; } }]
}
},
"user":
{
fields:
{
"id": { type: "id", isEditable: false, createReq: 0, foreignKey: null },
"domain": { type: "string", isEditable: false, createReq: 0, foreignKey: null },
"domainid": { type: "string", isEditable: false, createReq: 0, foreignKey: null },
"roles": { type: "string", isEditable: false, createReq: 0, foreignKey: null },
"username": { type: "string", isEditable: true, createReq: 2, foreignKey: null },
"password": { type: "secret", isEditable: false, createReq: 2, foreignKey: null },
"email": { type: "string", isEditable: true, createReq: 2, foreignKey: null },
"firstname": { type: "string", isEditable: true, createReq: 2, foreignKey: null },
"lastname": { type: "string", isEditable: true, createReq: 2, foreignKey: null },
"createdtime": { type: "timestamp", isEditable: false, createReq: 0, foreignKey: null }
},
readConditionStrings: [{ roles: ["member", "owner", "admin"], fn: function(u) { return ""; } }],
validators:
{
create: [{ roles: ["guest"], fn: function(n) { return true; } }],
update: [{ roles: ["owner", "admin"], fn: function(u, o, n) { return true; } }],
delete: [{ roles: ["admin"], fn: function(o) { return true; } }]
}
},
"item":
{
fields:
{
"id": { type: "id", isEditable: false, createReq: 0, foreignKey: null },
"ownerid": { type: "int", isEditable: false, createReq: 0, foreignKey: { foreignEntity: "user", resolvedKeyName: "owner" }},
"name": { type: "string", isEditable: true, createReq: 2, foreignKey: null },
"date": { type: "int", isEditable: true, createReq: 2, foreignKey: null },
"createdtime": { type: "timestamp", isEditable: false, createReq: 0, foreignKey: null }
},
readConditionStrings: [{ roles: ["owner", "admin"], fn: function(u) { return ""; } }],
validators:
{
create: [{ roles: ["member"], fn: function(n) { return true; } }],
update: [{ roles: ["owner", "admin"], fn: function(u, o, n) { return true; } }],
delete: [{ roles: ["owner", "admin"], fn: function(o) { return true; } }]
}
},
"message":
{
fields:
{
"id": { type: "id", isEditable: false, createReq: 0, foreignKey: null },
"ownerid": { type: "int", isEditable: false, createReq: 0, foreignKey: { foreignEntity: "user", resolvedKeyName: "owner" }},
"recipientid": { type: "int", isEditable: false, createReq: 2, foreignKey: { foreignEntity: "user", resolvedKeyName: "recipient" }},
"text": { type: "string", isEditable: false, createReq: 2, foreignKey: null },
"flagged": { type: "boolean", isEditable: true, createReq: 0, foreignKey: null },
"createdtime": { type: "timestamp", isEditable: false, createReq: 0, foreignKey: null }
},
readConditionStrings:
[
{ roles: ["member"], fn: function(u) { return "ownerid=" + u + "|recipientid=" + u; } },
{ roles: ["admin"], fn: function(u) { return ""; } }
],
validators:
{
create: [{ roles: ["member"], fn: function(n) { return true; } }],
update: [{ roles: ["member", "admin"], fn: function(u, o, n) { return u === o.recipientid; } }],
delete: [{ roles: ["admin"], fn: function(o) { return true; } }]
}
}
}
};
(The MIT License)
Copyright (c) 2017 Christopher Tjong christophertjong@hotmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Config based REST API framework
The npm package orion-api receives a total of 0 weekly downloads. As such, orion-api popularity was classified as not popular.
We found that orion-api demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.