2.9.2 • Published 8 years ago

ts-security-authentication-web v2.9.2

Weekly downloads
8
License
ISC
Repository
-
Last release
8 years ago

ts-security-authentication-web

A lightweight Typescript Security Identity Framework with Platform-Agnostic purposes (slightly based on WIF).

1. Getting Started

1.1 Installing

Install package from using npm

	npm install --save ts-security-authentication-web

1.2 Build

Configure your build system to copy the files from node_modules/ts-security-authentication-web to your dist/vendor/ts-security-authentication-web folder.

1.3 Configuring

Recommendation to use SystemJS to load the package at runtime.

System.config({ 
  map: {
    'ts-security-authentication-web': 'vendor/ts-security-authentication-web/dist/prod/js/src/'
  },
  packages: {
    'ts-security-authentication-web': {
      main: 'index.js'
    }
  }
 });

or

System.config({ 
  packageConfigPaths: ['vendor/ts-security-authentication-web/package.json']
 });

2. Using

2.1 Initializing

To initialize, is needed to invoke the Init method.

let config :IAuthenticationSettings = {
        authority: 'http://idp-teste.tjmt.jus.br',
        client_id: '2380',
        client_url: 'http://localhost:5555/'
};
AuthenticationContext.Current.Init(config).then(() => {
    console.log('Initialized!');
});

2.2 Login

Request the login:

    AuthenticationContext.Current.Login();

2.2 Tokens

Get the tokens (contents and encoded):

    let jsons: any[] = AuthenticationContext.Current.TokensContents.tokensContentsToArray(true);

2.3 Events

OnTokenObtained:

    let loginProcess = () => {
        let jsons: any[] = AuthenticationContext.Current.TokensContents.tokensContentsToArray(true);
        SecurityContextInitializer.InitializeWithTokens(jsons);
        console.debug('Authenticated as: ' + SecurityContext.Current.Principal.Identity.Name);
        return jsons;
    };
    AuthenticationContext.Current.AddOnTokenObtained(loginProcess);

3 Sample

Working sample:

let config :IAuthenticationSettings = {
        authority: 'http://idp-teste.tjmt.jus.br',
        client_id: '2380',
        client_url: 'http://localhost:5555/'
};

AuthenticationContext.Current.Init(config).then(() => {
    
    let loginProcess = () => {
        let jsons = AuthenticationContext.Current.TokensContents.tokensContentsToArray(true);
        SecurityContextInitializer.InitializeWithTokens(jsons);
        console.debug('Authenticated as: ' + SecurityContext.Current.Principal.Identity.Name);
        return jsons;
    };

    AuthenticationContext.Current.AddOnTokenObtained(loginProcess);
    AuthenticationContext.Current.Login();

});
2.9.2

8 years ago

3.0.0-alpha.32

8 years ago

3.0.0-alpha.31

8 years ago

3.0.0-alpha.30

8 years ago

3.0.0-alpha.29

8 years ago

3.0.0-alpha.28

8 years ago

3.0.0-alpha.27

8 years ago

3.0.0-alpha.26

8 years ago

3.0.0-alpha.25

8 years ago

3.0.0-alpha.24

8 years ago

3.0.0-alpha.23

8 years ago

3.0.0-alpha.22

8 years ago

3.0.0-alpha.21

8 years ago

3.0.0-alpha.20

8 years ago

3.0.0-alpha.19

8 years ago

3.0.0-alpha.18

8 years ago

3.0.0-alpha.17

8 years ago

3.0.0-alpha.16

8 years ago

3.0.0-alpha.15

8 years ago

3.0.0-alpha.14

8 years ago

3.0.0-alpha.13

8 years ago

3.0.0-alpha.12

8 years ago

3.0.0-alpha.11

8 years ago

3.0.0-alpha.10

8 years ago

3.0.0-alpha.9

8 years ago

3.0.0-alpha.8

8 years ago

3.0.0-alpha.7

8 years ago

3.0.0-alpha.6

8 years ago

3.0.0-alpha.5

8 years ago

3.0.0-alpha.4

8 years ago

3.0.0-alpha.3

8 years ago

3.0.0-alpha.2

8 years ago

3.0.0-alpha.1

8 years ago

2.9.1

8 years ago

2.9.0

8 years ago

2.8.1

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago