0.10.1 • Published 6 years ago

immutable-app-auth v0.10.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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/

0.10.1

6 years ago

0.10.0

6 years ago

0.9.42

7 years ago

0.9.41

7 years ago

0.9.40

7 years ago

0.9.39

7 years ago

0.9.38

7 years ago

0.9.37

7 years ago

0.9.36

7 years ago

0.9.35

7 years ago

0.9.34

7 years ago

0.9.33

7 years ago

0.9.32

7 years ago

0.9.31

7 years ago

0.9.30

7 years ago

0.9.29

7 years ago

0.9.28

7 years ago

0.9.27

7 years ago

0.9.26

7 years ago

0.9.25

7 years ago

0.9.24

7 years ago

0.9.23

7 years ago

0.9.22

7 years ago

0.9.21

7 years ago

0.9.20

7 years ago

0.9.19

7 years ago

0.9.18

7 years ago

0.9.17

7 years ago

0.9.16

7 years ago

0.9.15

7 years ago

0.9.14

7 years ago

0.9.13

7 years ago

0.9.12

7 years ago

0.9.11

7 years ago

0.9.10

7 years ago

0.9.9

7 years ago

0.9.8

7 years ago

0.9.7

7 years ago

0.9.6

7 years ago

0.9.4

7 years ago

0.9.3

7 years ago

0.9.2

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.71

7 years ago

0.8.70

7 years ago

0.8.69

7 years ago

0.8.68

7 years ago

0.8.67

7 years ago

0.8.66

7 years ago

0.8.65

7 years ago

0.8.64

7 years ago

0.8.63

7 years ago

0.8.62

7 years ago

0.8.61

7 years ago

0.8.60

7 years ago

0.8.59

7 years ago

0.8.58

7 years ago

0.8.57

7 years ago

0.8.56

7 years ago

0.8.55

7 years ago

0.8.54

7 years ago

0.8.53

7 years ago

0.8.52

7 years ago

0.8.51

7 years ago

0.8.50

7 years ago

0.8.49

7 years ago

0.8.48

7 years ago

0.8.47

7 years ago

0.8.46

7 years ago

0.8.45

7 years ago

0.8.44

7 years ago

0.8.43

7 years ago

0.8.42

7 years ago

0.8.41

7 years ago

0.8.40

7 years ago

0.8.39

7 years ago

0.8.38

7 years ago

0.8.37

7 years ago

0.8.36

7 years ago

0.8.35

7 years ago

0.8.34

7 years ago

0.8.33

7 years ago

0.8.32

7 years ago

0.8.31

7 years ago

0.8.30

7 years ago

0.8.29

7 years ago

0.8.28

7 years ago

0.8.27

7 years ago

0.8.26

7 years ago

0.8.25

7 years ago

0.8.24

7 years ago

0.8.23

7 years ago

0.8.22

7 years ago

0.8.21

7 years ago

0.8.20

7 years ago

0.8.19

7 years ago

0.8.18

7 years ago

0.8.17

7 years ago

0.8.16

7 years ago

0.8.15

7 years ago

0.8.14

7 years ago

0.8.13

7 years ago

0.8.12

7 years ago

0.8.11

7 years ago

0.8.10

7 years ago

0.8.9

7 years ago

0.8.8

7 years ago

0.8.7

7 years ago

0.8.6

7 years ago

0.8.5

7 years ago

0.8.4

7 years ago

0.8.3

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.28

7 years ago

0.7.27

7 years ago

0.7.26

7 years ago

0.7.25

7 years ago

0.7.24

7 years ago

0.7.23

7 years ago

0.7.22

7 years ago

0.7.21

7 years ago

0.7.20

7 years ago

0.7.19

7 years ago

0.7.18

7 years ago

0.7.17

7 years ago

0.7.16

7 years ago

0.7.15

7 years ago

0.7.14

7 years ago

0.7.13

7 years ago

0.7.12

7 years ago

0.7.11

7 years ago

0.7.10

7 years ago

0.7.9

7 years ago

0.7.8

7 years ago

0.7.7

7 years ago

0.7.6

7 years ago

0.7.5

7 years ago

0.7.4

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.8

7 years ago

0.6.7

7 years ago

0.6.6

7 years ago

0.6.5

7 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.48

7 years ago

0.5.47

7 years ago

0.5.46

7 years ago

0.5.45

7 years ago

0.5.44

7 years ago

0.5.43

7 years ago

0.5.42

7 years ago

0.5.41

7 years ago

0.5.40

7 years ago

0.5.39

7 years ago

0.5.38

7 years ago

0.5.37

7 years ago

0.5.36

7 years ago

0.5.35

7 years ago

0.5.34

7 years ago

0.5.33

7 years ago

0.5.32

7 years ago

0.5.31

7 years ago

0.5.30

7 years ago

0.5.29

7 years ago

0.5.28

7 years ago

0.5.27

7 years ago

0.5.26

7 years ago

0.5.25

7 years ago

0.5.24

7 years ago

0.5.23

7 years ago

0.5.22

7 years ago

0.5.21

7 years ago

0.5.20

7 years ago

0.5.19

7 years ago

0.5.18

8 years ago

0.5.17

8 years ago

0.5.16

8 years ago

0.5.15

8 years ago

0.5.14

8 years ago

0.5.13

8 years ago

0.5.12

8 years ago

0.5.11

8 years ago

0.5.10

8 years ago

0.5.9

8 years ago

0.5.8

8 years ago

0.5.7

8 years ago

0.5.6

8 years ago

0.5.5

8 years ago

0.5.4

8 years ago

0.5.3

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.65

8 years ago

0.4.64

8 years ago

0.4.63

8 years ago

0.4.62

8 years ago

0.4.61

8 years ago

0.4.60

8 years ago

0.4.59

8 years ago

0.4.58

8 years ago

0.4.57

8 years ago

0.4.56

8 years ago

0.4.55

8 years ago

0.4.54

8 years ago

0.4.53

8 years ago

0.4.52

8 years ago

0.4.51

8 years ago

0.4.50

8 years ago

0.4.49

8 years ago

0.4.48

8 years ago

0.4.47

8 years ago

0.4.46

8 years ago

0.4.45

8 years ago

0.4.44

8 years ago

0.4.43

8 years ago

0.4.42

8 years ago

0.4.41

8 years ago

0.4.40

8 years ago

0.4.39

8 years ago

0.4.38

8 years ago

0.4.37

8 years ago

0.4.36

8 years ago

0.4.35

8 years ago

0.4.34

8 years ago

0.4.33

8 years ago

0.4.32

8 years ago

0.4.31

8 years ago

0.4.30

8 years ago

0.4.29

8 years ago

0.4.28

8 years ago

0.4.27

8 years ago

0.4.26

8 years ago

0.4.25

8 years ago

0.4.24

8 years ago

0.4.23

8 years ago

0.4.22

8 years ago

0.4.21

8 years ago

0.4.20

8 years ago

0.4.19

8 years ago

0.4.18

8 years ago

0.4.17

8 years ago

0.4.16

8 years ago

0.4.15

8 years ago

0.4.14

8 years ago

0.4.13

8 years ago

0.4.12

8 years ago

0.4.11

8 years ago

0.4.9

8 years ago

0.4.8

8 years ago

0.4.7

8 years ago

0.4.6

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.16

8 years ago

0.2.15

8 years ago

0.2.14

8 years ago

0.2.13

8 years ago

0.2.12

8 years ago

0.2.11

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.65

8 years ago

0.0.64

8 years ago

0.0.63

8 years ago

0.0.62

8 years ago

0.0.61

8 years ago

0.0.60

8 years ago

0.0.59

8 years ago

0.0.58

8 years ago

0.0.57

8 years ago

0.0.56

8 years ago

0.0.55

8 years ago

0.0.54

8 years ago

0.0.53

8 years ago

0.0.52

8 years ago

0.0.51

8 years ago

0.0.50

8 years ago

0.0.49

8 years ago

0.0.48

8 years ago

0.0.47

8 years ago

0.0.46

8 years ago

0.0.45

8 years ago

0.0.44

8 years ago

0.0.43

8 years ago

0.0.42

8 years ago

0.0.41

8 years ago

0.0.40

8 years ago

0.0.39

8 years ago

0.0.38

8 years ago

0.0.37

8 years ago

0.0.36

8 years ago

0.0.35

8 years ago

0.0.34

8 years ago

0.0.33

8 years ago

0.0.32

8 years ago

0.0.31

8 years ago

0.0.30

8 years ago

0.0.29

8 years ago

0.0.28

8 years ago

0.0.27

8 years ago

0.0.26

8 years ago

0.0.25

8 years ago

0.0.24

8 years ago

0.0.23

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago