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.
@vcita/oauth-client-nestjs
Advanced tools
This package includes client oauth authentication module based upon NestJS framework.
This package includes vcita authentication, and can also interact with additional providers.
Using this package you will be able to:
Authenticate incoming requests
IdP
(Identity Provider):warning: Usage of cookies will be deprecated.
Object allowing to make requests to vCita's services (AKA consuming Platform API's) safely through the API-GW
Utilities for rapid testing and developing
testing
environmentsdevelopment
environmentsInstall this package using npm in your NestJS app.
npm install @vcita/oauth-client-nestjs
You must have these env variables available on your application (accessible through process.env.<env-var>
):
You may do so by adding them to your .env
.
:bulb: When opening a project from template, you will only need to add values or make sure they are filled correctly
:lock_with_ink_pen: When deploying your project, some values will be overridden with deployment secrets (this is good)
Env var | Explanation | Development Value | Deployment Overridden |
---|---|---|---|
OAUTH_CLIENT_ID | String representing oauth application uid | Obtained when registering app | Yes |
OAUTH_CLIENT_SECRET | String representing oauth application secret | Obtained when registering app | Yes |
OAUTH_SERVER | URL of frontend oauth-grant-flow start (frontage). | http://localhost:7200/app/oauth/authorize | Yes |
OAUTH_REDIRECT_URI | URL of redirection in a oauth-grant-flow | Location of your service in development. Example: http://localhost:47745 | Yes |
API_GW_SERVER | URL of vCita's API-GW | Will be explained in section | Yes |
AUTHORIZATION_SERVER | URL of vCita's Authorization Server | http://localhost:7100 | Yes |
CUSTOM_ENTITIES | Array of location(s) of additional entities | ["/home/node_modules/@vcita/oauth-client-nestjs/dist/oauth/**/*.entity.js","./node_modules/@vcita/oauth-client-nestjs/dist/oauth/**/*.entity.js"] | No |
After the package installation, you must generate and run a new migration for oauth module - migration docs
To use the package content we must first import the OauthModule
into our root module (AppModule
for most cases).
This is a dynamic module, use it you should call register method and supply object complying with ApplicationConfig
interface.
OauthModule.register({ mainRoute: '' })
mainRoute - the default route to redirect to after OAuth completed.
:warning: Note!
The interface will be changed on version 2.0.0
As an Internal Service you have 2 options to consume a Platform API:
To consume Platform APIs you must use the InternalProxyService
object - a provider exported by the OauthModule
.
To use the provider you must declare it as a dependency of the consuming class so NestJS would inject it at initialization.
@Processor('channels')
export class ChannelsProcessor extends BaseProcessor { // consuming class
constructor(
private readonly internalProxy: InternalProxyService, // NestJS will inject the `InternalProxyService` fatory object
) {
super();
}
}
:bulb: Now
ChannelProcessor
object is automatically injected withInternalProxyService
intance when NestJS framework initializes.
This object exposes methods for making an HTTP requests: getRequest, postRequst, putRequest, deleteRequest for proper usage.
Those methods can be used for both Platform API consuming by simply giving the last argument actingAs
.
Examples:
// Request example fitting option 1
import { ActorType } from "@vcita/oauth-client-nestjs";
this.internalProxy.getRequest<ResponseDataType>(
'platform/v1/test',
6,
{ query_param: 'some value' }
)
/* Reuest example fitting option 2
* Note this invocation contains another argument to the same method!
* This argument is the `actingAs` argument
*/
this.internalProxy.getRequest<ResponseDataType>(
'platform/v1/test',
6,
{ query_param: 'some value' },
actor.getActingAs(ActorType.STAFF)
)
:bulb: Each HTTP request method have a different interface, but they all allow the
actingAs
optional argument. Also notice that without the optional argument given, the default behaviour is of option 1!
:warning: Note!
This section is not final and might be subject to various changes in the next version.
As an application you must use the OAuthHttpAppService
.
To obtain this object you must declare it's factory object OauthHttpService
as a dependency of the consumer.
OauthHttpService
is a provider exported by the OauthModule
.
Example:
@Injectable()
export class ConnectorService { // Consumer class
private vcitaOauthHttpService: OAuthHttpAppService;
constructor(
httpClient: OauthHttpService, // NestJS will inject the `OAuthHttpAppService` fatory object
) {
this.vcitaOauthHttpService = httpClient.getInstance('vcita'); // Getting the proper instance to consume vCita's Platform APIs
}
async doWork(staffUid: string, path: string) {
const platformApiAns = await this.vcitaOauthHttpService.getRequest(
staffUid,
path,
);
return 'Answer from Platform Api is: ' + platformApiAns.toString();
}
}
There are cases where an internal service will need to call some external api.
We provide a way for the external api to authenticate that some arbitrary incoming API request was made by vCita's eco-system (one of vCita's internal services to be exact).
Example use case:
Some external application/service might not care, but those who do care we offer a mechanism for authenticating.
TBD
FAQs
Oauth2 Generic Vcita Integration
The npm package @vcita/oauth-client-nestjs receives a total of 25 weekly downloads. As such, @vcita/oauth-client-nestjs popularity was classified as not popular.
We found that @vcita/oauth-client-nestjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
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.