loopback/lib/models
Raymond Feng 9fb60174f9 Merge pull request #519 from fabien/fix/error-response
Fix embedsMany/findById to return proper 404 response
2014-09-02 22:42:40 -07:00
..
README.md Update README for application model 2013-12-19 13:42:12 -08:00
access-context.js Pass in remotingContext for ACL 2014-08-07 22:19:27 -07:00
access-token.js Make sure AccessToken extends from PersistedModel 2014-08-18 21:44:38 -07:00
acl.js Fix doc for the EXECUTE 2014-08-07 10:33:36 -07:00
application.js Merge branch 'master' into 2.0 2014-06-13 10:09:25 +02:00
change.js models/change: fix typo 2014-07-15 09:14:54 +02:00
checkpoint.js checkpoint: fix `current()` 2014-07-11 17:07:22 +02:00
email.js Improvements to JSDoc comments 2014-03-14 10:28:31 -07:00
index.js Remove the dangling require 2014-01-16 09:12:52 -08:00
model.js Merge pull request #519 from fabien/fix/error-response 2014-09-02 22:42:40 -07:00
persisted-model.js Fix "callbacl" by "callback" in doc 2014-08-05 15:17:11 +02:00
role.js Set the role id to be generated 2014-06-10 16:38:37 -07:00
user.js Fix reference to app 2014-08-07 21:45:18 -07:00

README.md

Application

Application model represents the metadata for a client application that has its own identity and associated configuration with the LoopBack server.

Each application has the following basic properties:

  • id: Automatically generated id
  • name: Name of the application (required)
  • description: Description of the application (optional)
  • icon: URL of the icon
  • status: Status of the application, such as production/sandbox/disabled
  • created: Timestamp of the record being created
  • modified: Timestamp of the record being modified

An application has the following properties linking to users:

  • owner: The user id of the developer who registers the application
  • collaborators: A array of users ids who have permissions to work on this app

oAuth 2.0 settings

  • url: The application url
  • callbackUrls: An array of preregistered callback urls for oAuth 2.0
  • permissions: An array of oAuth 2.0 scopes that can be requested by the application

Security keys

The following keys are automatically generated by the application creation process. They can be reset upon request.

  • clientKey: Secret for mobile clients
  • javaScriptKey: Secret for JavaScript clients
  • restApiKey: Secret for REST APIs
  • windowsKey: Secret for Windows applications
  • masterKey: Secret for REST APIS. It bypasses model level permissions

Push notification settings

The application can be configured to support multiple methods of push notifications.

  • pushSettings

    pushSettings: { apns: { certData: config.apnsCertData, keyData: config.apnsKeyData, production: false, // Development mode pushOptions: { // Extra options can go here for APN }, feedbackOptions: { batchFeedback: true, interval: 300 } }, gcm: { serverApiKey: config.gcmServerApiKey } }

Authentication schemes

  • authenticationEnabled
  • anonymousAllowed
  • authenticationSchemes

Authentication scheme settings

  • scheme: Name of the authentication scheme, such as local, facebook, google, twitter, linkedin, github
  • credential: Scheme-specific credentials

APIs for Application model

In addition to the CRUD methods, the Application model also has the following apis:

Register a new application

You can register a new application by providing the owner user id, application name, and other properties in the options object.

Application.register('rfeng', 'MyApp1',
    {description: 'My first loopback application'},
    function (err, result) {
        var app = result;
    ...
});

Reset keys

You can reset keys for a given application by id.

Application.resetKeys(appId, function (err, result) {
    var app = result;
    ...
});

Authenticate by appId and key

You can authenticate an application by id and one of the keys. If successful, it calls back with the key name in the result argument. Otherwise, the keyName is null.

Application.authenticate(appId, clientKey, function (err, keyName) {
        assert.equal(keyName, 'clientKey');
        ...
});