@starnetbih/au2-servicestack-auth
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

au2-servicestack-auth

Aurelia 2 auth library for servicestack. JWT Tokens are maintained via Secure HttpOnly Cookies. This plugin depends on:

  • @starnetbih/au2-configuration
  • @starnetbih/au2-api

Make sure that your src directory contains config directory with config.json file in it. So:

  • app
    • src
      • config
        • config.json

Add 'au2-api' section with key 'authApi' with url and auth set to true.

config.json example

{
 "au2-api": {
  "authApi": {
   "url": "https://localhost:5010",
   "auth": true
  }
 }
}

Full disclosure: this plugin is in alpha stage. Use at your own risk.

Installation

npm install @starnetbih/au2-servicestack-auth or yarn add @starnetbih/au2-servicestack-auth

Usage

import { IAuthService, IUserProfile, SS_AUTH_CHANNEL_SIGNED_IN, SS_AUTH_CHANNEL_SIGNED_OUT } from '@starnetbih/au2-servicestack-auth';
import { IEventAggregator } from 'aurelia';

export class MyApp {
 constructor(
    @IAuthService private Auth: IAuthService,
    @IEventAggregator readonly EventAggregator: IEventAggregator) {
        this.EventAggregator.subscribe(SS_AUTH_CHANNEL_SIGNED_IN, (usr) => {
            console.log(`${(usr as IUserProfile).displayName} signed in!`);
            console.log(usr);
        });
        this.EventAggregator.subscribe(SS_AUTH_CHANNEL_SIGNED_OUT, () => {
            console.log('User signed out');
        });
    }

    async attached() {
       await this.Auth.signIn({ username: "admin", password: "admin" });
       await this.Auth.signOut();
    }
}

Dependencies (4)

Dev Dependencies (25)

Package Sidebar

Install

npm i @starnetbih/au2-servicestack-auth

Weekly Downloads

8

Version

0.5.0

License

MIT

Unpacked Size

17.6 kB

Total Files

11

Last publish

Collaborators

  • hdzcalmir
  • aner78
  • stefannj
  • zeko77