Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

onestop-auth

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onestop-auth

Onestop Auth Module

  • 1.2.6
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Onestop Auth Module

AuthModule is a set of essential modules for Onestop Angular application.

What's included:

  • Login and Spaces Select Page Templete
  • Authentication Service
  • Spaces Service to store and retrieve spaces/spaceId/user roles in localstorage
  • Onestop http interceptor to manage http calls, eg. setup common headers and handle errors

Installation

Before install this module, make sure your npm are under onstop npm registry. To check your npm registry, run

npm config get registry

To change your npm registry to Onestop npm, run

npm config set registry http://packages.prod.1-stop.biz/npm/npm/

To install this module, under the project directory run

npm install --save onestop-auth

Getting started

Import the AuthModule in your root application module:

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';

import {AppComponent} from './app.component';
import {AuthInterceptor, AuthModule} from 'onestop-auth';
import {AppRoutingModule} from './app-routing.module';
import {HomeComponent} from './home.component';
import {HTTP_INTERCEPTORS} from '@angular/common/http';

@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        // authenticationUrl and appPrefix are required
        AuthModule.forRoot({
            authenticationUrl: "https://api-40.1-stop.biz/CPMSGW/api/v1/user/login",
            authorisationBaseUrl: "https://api-40.1-stop.biz/CPMSGW/api/v1",
            appPrefix: "CPMS_"
        })
    ],
    declarations: [AppComponent, HomeComponent],
    providers: [{
        provide: HTTP_INTERCEPTORS,
        useClass: AuthInterceptor,
        multi: true,
    }],
    bootstrap: [AppComponent]
})
export class AppModule {
}

More configuration details see Configuration Options

Setting routes:

import {RouterModule, Routes} from '@angular/router';
import {NgModule} from '@angular/core';
import {HomeComponent} from './home.component';
import {LoginComponent, SpacesComponent} from 'onestop-auth';

const routes: Routes = [
    {
        path: '',
        component: HomeComponent
    },
    {
        path: 'login',
        component: LoginComponent,
    },
    {
        path: 'spaces',
        component: SpacesComponent,
    },
    { path: '', redirectTo: 'login', pathMatch: 'full'},
    { path: '**', redirectTo: ''},
];

@NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule]
})
export class AppRoutingModule {
}

Configuration

NameDefaultDescription
*authenticationUrlnullThe Authentication URL to post user name and password, eg. https://api-40.1-stop.biz/CPMSGW/api/v1/user/login
*appPrefixnullOnestop App prefix, eg. CPMS_
authorisationBaseUrlnullThe base url in relation to user space url and user roles url
redirectTo/The Url that will be redirected to when successfully login
clientId'1STOP'ClientId in Authentication payload
spaceIdnullProvide a default Space ID
defaultSpaceIdtrueIf default space ID is not provided, and you don't want to go to space selection page to select a ID, you can set this config to true, then the app will skip spaces page and set up first space in user's available spaces.
spaceUrlspacesSpace selection page URL
userSpacesUrl/user/spaceIdsURL to get user spaces, will combine with authorisationBaseUrl
userRolesUrl/user/facilitiesURL to get user roles, will combine with authorisationBaseUrl

FAQs

Package last updated on 30 Nov 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc