immutable-app-auth
Immutable app authentication module
Last updated a year ago by ersun.warncke .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install immutable-app-auth 
SYNC missed versions from official npm registry.

immutable-app-auth

Immutable App Auth integrates with Immutable App to provide device and session tracking, authentication and access control.

Immutable App Auth currently supports authentication via Facebook and Google.

Immutable App Auth integrates with Immutable Access Control and loads the access control rules and roles that are used for access control.

Immutable App Auth v0.10 and Immutable Core Model v4

Immutable App Auth v0.10 is required to support the breaking changes that were made in Immutable Core Model v4.

Immutable App v0.10 is not compatible with Imutable Core Model v3.

!!! WARNING !!!

geoip support has been removed. this will be added back in a modified way at a later time.

Using Immutable App Auth

app.js
------

const immutableApp = require('immutable-app')`
const immutableAppAuth = require('immutable-app-auth')

immutableAppAuth.config({
    device: {
        cookie: {
            domain: '.your-app.com',
        },
    },
    facebook: {
        callbackHost: 'https://your-app.com',
        clientId: 'XXX',
        clientSecret: 'XXX',
    },
    google: {
        callbackHost: 'https://your-app.com',
        clientId: 'XXX',
        clientSecret: 'XXX',
    },
    session: {
        cookie: {
            domain: '.your-app.com',
        },
    },
})

immutableApp.config({ ... })

In this example Facebook and Google are configured as authentication providers and the domain for the device and session cookies is set.

device configuration

  • cookie - object with device cookie config
    • domain - domain name for device cookie ('')
    • expires - expiration defaults to far future (new Date(2147483647000))
    • name - name of cookie to set ('deviceId')

Any other properties set will be used as options for res.cookie()

facebook configuation

  • callbackHost - protocol and host for callback url ('')
  • callbackPath - path for callback url ('/auth/facebook/callback')
  • clientId - facebook client id ('')
  • clientSecret - facebook client secret ('')
  • loginPath - login path that redirects to facebook ('/auth/facebook/login')profileFields - profile data to request from facebook (['id', 'emails', 'name', 'gender', 'picture.type(large)'])
  • scope - scope for facebook access (['email'])

google configuration

  • callbackHost - protocol and host for callback url ('')
  • callbackPath - path for callback url ('/auth/google/callback')
  • clientId - google client id ('')
  • clientSecret - google client secret ('')
  • loginPath - login path that redirects to google ('/auth/google/login')
  • scope - scope for google access (['email'])

session configuration

  • access - object with config for access id
    • cookie - object with access id cookie config
  • cookie - object with session cookie config
    • domain - domain name for session cookie ('')
    • expires - expiration defaults to session context only (0)
    • name - name of cookie to set ('sessionId')
  • currencies - object with 3 letter code (capitalized) and name of supported currencies for app ({USD: 'United States Dollar'})
  • defaultCurrency - string default currency code (USD)
  • defaultLanguage - string default language (eng)
  • defaultTimezone - string timezone (UTC)
  • geoip - string abs path to maxmind geoip2 database file
  • languages - object with language 3 digit lower case language code and anme ({eng: 'English'})

Immutable App Auth architecture

Immutable App Auth identifies clients by device, session and account.

device

The purpose of device tracking is track multiple different sessions and account using the same physical device.

By default the device id is based on the user agent and ip address of the client. More elaborate "fingerprinting" methods are possible but the basic idea is to identify distinct clients without relying on cookies.

A deviceId cookie will be set but if the cookie is not sent by the client the same deviceId will be calculate again from the user agent and ip address.

session

All requests take place within the context of a session.

Immutable Core and many other components of the Immutable framework use a session and Immutable App Auth initializes this session.

If the client sends a sessionId cookie an existing session will be loaded if the id exists.

If a session does not exist for the client a new session will be created

session-location

The location for the session is tracked using both MaxMind GeoIP and navigator.location in the browser.

profile

A profile is created for each session if it does not exist and if the session is logged in then the profile for the account is loaded.

The profile contains information like location, timezone, language and currency which will be set automatically unless set by the user.

device-session

Whenever a new session is created a deviceSession record is created to link the session to the current device.

session-account

When a sessionId cookie is sent by the client the sessionAccount model is queried to check if the session is associated with an account. If the session is associated with an account the roles for that account will be loaded and used for access control.

Whenever a client creates or logs into an account a new sessionAccount record is created to link the current session to the account.

role-account

The roleAccount model links accounts to roles.

role

The role model provides the names of roles and the types of permissions the role grants - i.e. access, assign, revoke.

Roles are assigned to accounts via roleAccount and access rules are assigned to roles via roleAccess.

If the role has access permission only then sessions with the role will be able to access all of the resources defined by the role's linked access rules.

If the role has assign or revoke permissions then session with the role will be able to assign and/or revoke any of the role's linked access rules to other accounts if they also have the appropriate permissions to administer roles.

role-access

The roleAccess model links roles to access rules.

access

The access model provides access rules that can be linked to roles in order to assign them to accounts.

account

The account model consists solely of an id and createTime. All account data is stored in other models indexed by accountId.

The accountId is the default value used for determining ownership of records.

Models have an accountId property by default and whenever a model is created the accountId property will be populated from the session.

Models can specify alternative properties to use as an accessId but Immutable App Auth must be configured to load the alternative properties onto the session.

auth

Accounts can have one or more auth records from different auth providers. The auth record provides the details needed to identify an account such as email and password.

Immutable App Auth admin functionality

Immutable App Auth provides admin functionality for managing access control rules, accounts, and roles.

To administer Immutable App Auth go to: /admin/

Current Tags

  • 0.10.1                                ...           latest (a year ago)

350 Versions

  • 0.10.1                                ...           a year ago
  • 0.10.0                                ...           a year ago
  • 0.9.42                                ...           2 years ago
  • 0.9.41                                ...           2 years ago
  • 0.9.40                                ...           2 years ago
  • 0.9.39                                ...           2 years ago
  • 0.9.38                                ...           2 years ago
  • 0.9.37                                ...           2 years ago
  • 0.9.36                                ...           2 years ago
  • 0.9.35                                ...           2 years ago
  • 0.9.34                                ...           2 years ago
  • 0.9.33                                ...           2 years ago
  • 0.9.32                                ...           2 years ago
  • 0.9.31                                ...           2 years ago
  • 0.9.30                                ...           2 years ago
  • 0.9.29                                ...           2 years ago
  • 0.9.28                                ...           2 years ago
  • 0.9.27                                ...           2 years ago
  • 0.9.26                                ...           2 years ago
  • 0.9.25                                ...           2 years ago
  • 0.9.24                                ...           2 years ago
  • 0.9.23                                ...           2 years ago
  • 0.9.22                                ...           2 years ago
  • 0.9.21                                ...           2 years ago
  • 0.9.20                                ...           2 years ago
  • 0.9.19                                ...           2 years ago
  • 0.9.18                                ...           2 years ago
  • 0.9.17                                ...           2 years ago
  • 0.9.16                                ...           2 years ago
  • 0.9.15                                ...           2 years ago
  • 0.9.14                                ...           2 years ago
  • 0.9.13                                ...           2 years ago
  • 0.9.12                                ...           2 years ago
  • 0.9.11                                ...           2 years ago
  • 0.9.10                                ...           2 years ago
  • 0.9.9                                ...           2 years ago
  • 0.9.8                                ...           2 years ago
  • 0.9.7                                ...           2 years ago
  • 0.9.6                                ...           2 years ago
  • 0.9.4                                ...           2 years ago
  • 0.9.3                                ...           2 years ago
  • 0.9.2                                ...           2 years ago
  • 0.9.1                                ...           2 years ago
  • 0.9.0                                ...           2 years ago
  • 0.8.71                                ...           2 years ago
  • 0.8.70                                ...           2 years ago
  • 0.8.69                                ...           2 years ago
  • 0.8.68                                ...           2 years ago
  • 0.8.67                                ...           2 years ago
  • 0.8.66                                ...           2 years ago
  • 0.8.65                                ...           2 years ago
  • 0.8.64                                ...           2 years ago
  • 0.8.63                                ...           2 years ago
  • 0.8.62                                ...           2 years ago
  • 0.8.61                                ...           2 years ago
  • 0.8.60                                ...           2 years ago
  • 0.8.59                                ...           2 years ago
  • 0.8.58                                ...           2 years ago
  • 0.8.57                                ...           2 years ago
  • 0.8.56                                ...           2 years ago
  • 0.8.55                                ...           2 years ago
  • 0.8.54                                ...           2 years ago
  • 0.8.53                                ...           2 years ago
  • 0.8.52                                ...           2 years ago
  • 0.8.51                                ...           2 years ago
  • 0.8.50                                ...           2 years ago
  • 0.8.49                                ...           2 years ago
  • 0.8.48                                ...           2 years ago
  • 0.8.47                                ...           2 years ago
  • 0.8.46                                ...           2 years ago
  • 0.8.45                                ...           2 years ago
  • 0.8.44                                ...           2 years ago
  • 0.8.43                                ...           2 years ago
  • 0.8.42                                ...           2 years ago
  • 0.8.41                                ...           2 years ago
  • 0.8.40                                ...           2 years ago
  • 0.8.39                                ...           2 years ago
  • 0.8.38                                ...           2 years ago
  • 0.8.37                                ...           2 years ago
  • 0.8.36                                ...           2 years ago
  • 0.8.35                                ...           2 years ago
  • 0.8.34                                ...           2 years ago
  • 0.8.33                                ...           2 years ago
  • 0.8.32                                ...           2 years ago
  • 0.8.31                                ...           2 years ago
  • 0.8.30                                ...           2 years ago
  • 0.8.29                                ...           2 years ago
  • 0.8.28                                ...           2 years ago
  • 0.8.27                                ...           2 years ago
  • 0.8.26                                ...           2 years ago
  • 0.8.25                                ...           2 years ago
  • 0.8.24                                ...           2 years ago
  • 0.8.23                                ...           2 years ago
  • 0.8.22                                ...           2 years ago
  • 0.8.21                                ...           2 years ago
  • 0.8.20                                ...           2 years ago
  • 0.8.19                                ...           2 years ago
  • 0.8.18                                ...           2 years ago
  • 0.8.17                                ...           2 years ago
  • 0.8.16                                ...           2 years ago
  • 0.8.15                                ...           2 years ago
  • 0.8.14                                ...           2 years ago
  • 0.8.13                                ...           2 years ago
  • 0.8.12                                ...           2 years ago
  • 0.8.11                                ...           2 years ago
  • 0.8.10                                ...           2 years ago
  • 0.8.9                                ...           2 years ago
  • 0.8.8                                ...           2 years ago
  • 0.8.7                                ...           2 years ago
  • 0.8.6                                ...           2 years ago
  • 0.8.5                                ...           2 years ago
  • 0.8.4                                ...           2 years ago
  • 0.8.3                                ...           2 years ago
  • 0.8.2                                ...           2 years ago
  • 0.8.1                                ...           2 years ago
  • 0.8.0                                ...           2 years ago
  • 0.7.28                                ...           2 years ago
  • 0.7.27                                ...           2 years ago
  • 0.7.26                                ...           2 years ago
  • 0.7.25                                ...           2 years ago
  • 0.7.24                                ...           2 years ago
  • 0.7.23                                ...           2 years ago
  • 0.7.22                                ...           2 years ago
  • 0.7.21                                ...           2 years ago
  • 0.7.20                                ...           2 years ago
  • 0.7.19                                ...           2 years ago
  • 0.7.18                                ...           2 years ago
  • 0.7.17                                ...           2 years ago
  • 0.7.16                                ...           2 years ago
  • 0.7.15                                ...           2 years ago
  • 0.7.14                                ...           2 years ago
  • 0.7.13                                ...           2 years ago
  • 0.7.12                                ...           2 years ago
  • 0.7.11                                ...           2 years ago
  • 0.7.10                                ...           2 years ago
  • 0.7.9                                ...           2 years ago
  • 0.7.8                                ...           2 years ago
  • 0.7.7                                ...           2 years ago
  • 0.7.6                                ...           2 years ago
  • 0.7.5                                ...           2 years ago
  • 0.7.4                                ...           2 years ago
  • 0.7.3                                ...           2 years ago
  • 0.7.2                                ...           2 years ago
  • 0.7.1                                ...           2 years ago
  • 0.7.0                                ...           2 years ago
  • 0.6.8                                ...           2 years ago
  • 0.6.7                                ...           2 years ago
  • 0.6.6                                ...           2 years ago
  • 0.6.5                                ...           2 years ago
  • 0.6.4                                ...           2 years ago
  • 0.6.3                                ...           2 years ago
  • 0.6.2                                ...           2 years ago
  • 0.6.1                                ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.5.48                                ...           2 years ago
  • 0.5.47                                ...           2 years ago
  • 0.5.46                                ...           2 years ago
  • 0.5.45                                ...           2 years ago
  • 0.5.44                                ...           2 years ago
  • 0.5.43                                ...           2 years ago
  • 0.5.42                                ...           2 years ago
  • 0.5.41                                ...           2 years ago
  • 0.5.40                                ...           2 years ago
  • 0.5.39                                ...           2 years ago
  • 0.5.38                                ...           2 years ago
  • 0.5.37                                ...           2 years ago
  • 0.5.36                                ...           2 years ago
  • 0.5.35                                ...           2 years ago
  • 0.5.34                                ...           2 years ago
  • 0.5.33                                ...           2 years ago
  • 0.5.32                                ...           2 years ago
  • 0.5.31                                ...           2 years ago
  • 0.5.30                                ...           2 years ago
  • 0.5.29                                ...           2 years ago
  • 0.5.28                                ...           2 years ago
  • 0.5.27                                ...           2 years ago
  • 0.5.26                                ...           2 years ago
  • 0.5.25                                ...           2 years ago
  • 0.5.24                                ...           2 years ago
  • 0.5.23                                ...           2 years ago
  • 0.5.22                                ...           2 years ago
  • 0.5.21                                ...           2 years ago
  • 0.5.20                                ...           2 years ago
  • 0.5.19                                ...           2 years ago
  • 0.5.18                                ...           2 years ago
  • 0.5.17                                ...           2 years ago
  • 0.5.16                                ...           2 years ago
  • 0.5.15                                ...           2 years ago
  • 0.5.14                                ...           2 years ago
  • 0.5.13                                ...           2 years ago
  • 0.5.12                                ...           2 years ago
  • 0.5.11                                ...           2 years ago
  • 0.5.10                                ...           2 years ago
  • 0.5.9                                ...           2 years ago
  • 0.5.8                                ...           2 years ago
  • 0.5.7                                ...           2 years ago
  • 0.5.6                                ...           2 years ago
  • 0.5.5                                ...           2 years ago
  • 0.5.4                                ...           2 years ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.65                                ...           2 years ago
  • 0.4.64                                ...           2 years ago
  • 0.4.63                                ...           2 years ago
  • 0.4.62                                ...           2 years ago
  • 0.4.61                                ...           2 years ago
  • 0.4.60                                ...           2 years ago
  • 0.4.59                                ...           2 years ago
  • 0.4.58                                ...           2 years ago
  • 0.4.57                                ...           2 years ago
  • 0.4.56                                ...           2 years ago
  • 0.4.55                                ...           2 years ago
  • 0.4.54                                ...           2 years ago
  • 0.4.53                                ...           2 years ago
  • 0.4.52                                ...           2 years ago
  • 0.4.51                                ...           2 years ago
  • 0.4.50                                ...           2 years ago
  • 0.4.49                                ...           2 years ago
  • 0.4.48                                ...           2 years ago
  • 0.4.47                                ...           2 years ago
  • 0.4.46                                ...           2 years ago
  • 0.4.45                                ...           2 years ago
  • 0.4.44                                ...           2 years ago
  • 0.4.43                                ...           2 years ago
  • 0.4.42                                ...           2 years ago
  • 0.4.41                                ...           2 years ago
  • 0.4.40                                ...           2 years ago
  • 0.4.39                                ...           2 years ago
  • 0.4.38                                ...           2 years ago
  • 0.4.37                                ...           2 years ago
  • 0.4.36                                ...           2 years ago
  • 0.4.35                                ...           2 years ago
  • 0.4.34                                ...           2 years ago
  • 0.4.33                                ...           2 years ago
  • 0.4.32                                ...           2 years ago
  • 0.4.31                                ...           2 years ago
  • 0.4.30                                ...           2 years ago
  • 0.4.29                                ...           2 years ago
  • 0.4.28                                ...           2 years ago
  • 0.4.27                                ...           2 years ago
  • 0.4.26                                ...           2 years ago
  • 0.4.25                                ...           2 years ago
  • 0.4.24                                ...           2 years ago
  • 0.4.23                                ...           2 years ago
  • 0.4.22                                ...           2 years ago
  • 0.4.21                                ...           2 years ago
  • 0.4.20                                ...           2 years ago
  • 0.4.19                                ...           2 years ago
  • 0.4.18                                ...           2 years ago
  • 0.4.17                                ...           2 years ago
  • 0.4.16                                ...           2 years ago
  • 0.4.15                                ...           2 years ago
  • 0.4.14                                ...           2 years ago
  • 0.4.13                                ...           3 years ago
  • 0.4.12                                ...           3 years ago
  • 0.4.11                                ...           3 years ago
  • 0.4.9                                ...           3 years ago
  • 0.4.8                                ...           3 years ago
  • 0.4.7                                ...           3 years ago
  • 0.4.6                                ...           3 years ago
  • 0.4.5                                ...           3 years ago
  • 0.4.4                                ...           3 years ago
  • 0.4.3                                ...           3 years ago
  • 0.4.2                                ...           3 years ago
  • 0.4.1                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.2                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.16                                ...           3 years ago
  • 0.2.15                                ...           3 years ago
  • 0.2.14                                ...           3 years ago
  • 0.2.13                                ...           3 years ago
  • 0.2.12                                ...           3 years ago
  • 0.2.11                                ...           3 years ago
  • 0.2.10                                ...           3 years ago
  • 0.2.9                                ...           3 years ago
  • 0.2.8                                ...           3 years ago
  • 0.2.7                                ...           3 years ago
  • 0.2.6                                ...           3 years ago
  • 0.2.5                                ...           3 years ago
  • 0.2.4                                ...           3 years ago
  • 0.2.3                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.2.1                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.65                                ...           3 years ago
  • 0.0.64                                ...           3 years ago
  • 0.0.63                                ...           3 years ago
  • 0.0.62                                ...           3 years ago
  • 0.0.61                                ...           3 years ago
  • 0.0.60                                ...           3 years ago
  • 0.0.59                                ...           3 years ago
  • 0.0.58                                ...           3 years ago
  • 0.0.57                                ...           3 years ago
  • 0.0.56                                ...           3 years ago
  • 0.0.55                                ...           3 years ago
  • 0.0.54                                ...           3 years ago
  • 0.0.53                                ...           3 years ago
  • 0.0.52                                ...           3 years ago
  • 0.0.51                                ...           3 years ago
  • 0.0.50                                ...           3 years ago
  • 0.0.49                                ...           3 years ago
  • 0.0.48                                ...           3 years ago
  • 0.0.47                                ...           3 years ago
  • 0.0.46                                ...           3 years ago
  • 0.0.45                                ...           3 years ago
  • 0.0.44                                ...           3 years ago
  • 0.0.43                                ...           3 years ago
  • 0.0.42                                ...           3 years ago
  • 0.0.41                                ...           3 years ago
  • 0.0.40                                ...           3 years ago
  • 0.0.39                                ...           3 years ago
  • 0.0.38                                ...           3 years ago
  • 0.0.37                                ...           3 years ago
  • 0.0.36                                ...           3 years ago
  • 0.0.35                                ...           3 years ago
  • 0.0.34                                ...           3 years ago
  • 0.0.33                                ...           3 years ago
  • 0.0.32                                ...           3 years ago
  • 0.0.31                                ...           3 years ago
  • 0.0.30                                ...           3 years ago
  • 0.0.29                                ...           3 years ago
  • 0.0.28                                ...           3 years ago
  • 0.0.27                                ...           3 years ago
  • 0.0.26                                ...           3 years ago
  • 0.0.25                                ...           3 years ago
  • 0.0.24                                ...           3 years ago
  • 0.0.23                                ...           3 years ago
  • 0.0.17                                ...           3 years ago
  • 0.0.16                                ...           3 years ago
  • 0.0.15                                ...           3 years ago
  • 0.0.14                                ...           3 years ago
  • 0.0.13                                ...           3 years ago
  • 0.0.12                                ...           3 years ago
  • 0.0.11                                ...           3 years ago
  • 0.0.10                                ...           3 years ago
  • 0.0.9                                ...           3 years ago
  • 0.0.8                                ...           3 years ago
  • 0.0.7                                ...           3 years ago
  • 0.0.6                                ...           3 years ago
  • 0.0.5                                ...           3 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |