fle-ember-addon-data
v1.0.0-release.39
Published
Finish Line Events shared Ember-Data models.
Downloads
8
Readme
Finish Line Events - Ember Addon Data
This addon is responsible for providing data access and authentication to Finish Line Events applications.
- Board
- Planning & Documentation
- Rails
- Administrator Application
- Organizer Application
- Data Addon
- UI Addon
- SEO Application
How Does Authentication Work
Please refer to the Planning repository's document on Authentication.
Compatibility
- Ember.js v3.12 or above
- Ember CLI v2.13 or above
- Node.js v10 or above
Installation
ember install fle-ember-addon-data
Usage
Authentication
Ember Simple Auth (ESA) has been included with this application is automatically configured to authenticate with AWS Cognito.
Configuration
For the production edition of the application using this addon for authentication, the redirect URIs for signing in and signing out must be configured.
Inside the application's config/environment.js
, the following section should be added
to the production environment and the url to the Ember SPA being deploy to prodcution should
be used (replace the [...]
in the code below):
if (environment === 'production') {
ENV.APP['ember-simple-auth-aws-amplify'] = {
...ENV.APP['ember-simple-auth-aws-amplify'],
awsAmplifyAuth: {
config: {
oauth: {
redirectSignIn: 'https://[...].finishline.events/oauth',
redirectSignOut: 'https://[...].finishline.events/oauth'
}
}
}
};
}
NOTE do not forget that AWS Cognito will need to be updated to accomodate and accept the production edition URL that is specified in the configuration.
The session
Service
This addon ships with an enhanced Ember Simple Auth SessionService
that
includes alias-properties that fetch token payload data and also answer
questions about the role the user belongs to.
To enable this custom FleSessionService
, the session service must be created
in the application using this addon:
./node_modules/.bin/ember g service session
And then extend the SessionService
from this addon:
// app/services/session.js
import FleSession from 'fle-ember-addon-data/services/fle-session';
export default class SessionService extends FleSession {}
Injecting The session
Automatically
For convenience sake, the session
service can automatically be added to specific
scopes using and initializer
. To configure this initializer to be added to the
session
service to all controllers and routes, you can do the following:
./node_modules/.bin/ember g initializer session
// app/initializers/session.js
export function initialize(application) {
application.inject('controller', 'session', 'service:session');
application.inject('route', 'session', 'service:session');
}
export default {
initialize
};
Routing
Auto-Enabled Routes
By adding this addon into another application the sign-in
, sign-out
, and
oauth
route will automatically be included into your router.js
at runtime.
These routes can be invoked to sign-in
and sign-out
of the application, the
oauth
route is where AWS Cognito will redirect to after signing in/out.
Configure The application.js
Route
The application that installs this addon must ensure that its app/routes/application.js
extends the application route superclass provided by this addon. Here's how to
do that:
// app/routes/application.js
import FleApplicationRoute from 'fle-ember-addon-data/routes/application';
export default class ApplicationRoute extends FleApplicationRoute {
// ... the rest of your route here; e.g. initialize ember-intl
}
The secure
Route
By default, Ember Simple Auth (ESA) that ships with this addon is configured to protect the
route at and below /secure
with authentication and authorization. The application
that installs this addon should create the secure
route:
./node_modules/.bin/ember g route secure
The secure route should extend the ESA AuthenticatedRouteMixin
:
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
export default class SecureRoute extends Route.extend(AuthenticatedRouteMixin) {
get authenticationRoute() {
return 'sign-in';
}
// ...
}
Translations
You should make sure to configure ember-intl
accordingly. This addon ships with translations
describing model column names, their help-block, placeholder, and tooltip text.
The wrapTranslationsWithNamespace
should be set to true
.
Contributing
See the Contributing guide for details.
License
This project is licensed under the MIT License.