Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
ember-data-github
Advanced tools
Changelog
v0.6.0 (2018-02-14)
Readme
Ember Data abstraction for the GitHub REST API v3.
ember install ember-data-github
You need to choose how you wish to authenticate your GitHub requests using OAuth. ember-data-github
provides a simple
and direct mechanism that is specific to itself. Alternatively, you can use a more general authentication framework like
ember-simple-auth
.
If you already have a token to use the OAuth endpoints, such as a Personal access token, you must set the property
named githubAccessToken
on github-session
service with the currently logged in user's GitHub access token.
ember-simple-auth
If you are using ember-simple-auth (ESA) to authenticate, perhaps with
torii and ESA's torii-provider
, you can authenticate by creating a github
authorizer and extending ember-data-github
's adapter for each model you use. See the respective addon docs and
GitHub's OAuth docs to set it up.
Once you have a token, the authorizer will look like
// app/authorizers/github.js
import { inject as service } from '@ember/service';
import { isEmpty } from '@ember/utils';
import Base from 'ember-simple-auth/authorizers/base';
export default Base.extend({
session: service(),
authorize(sessionData, block) {
if (this.get('session.isAuthenticated') && !isEmpty(sessionData.access_token)) {
block('Authorization', `token ${sessionData.access_token}`);
}
}
});
assuming access_token
is the name of the property containing the token. This automatically injects the Authorization
header into the API requests using ESA mechanisms.
An extended adapter for github-user
would look like
// app/adapters/github-user.js
import GitHubUserAdapter from 'ember-data-github/adapters/github-user';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
export default GitHubUserAdapter.extend(DataAdapterMixin, {
authorizer: 'authorizer:github'
});
this.get('store').findRecord('github-user', '#');
this.get('store').findRecord('github-user', 'jimmay5469'); // get a user by user login
this.get('store').findRecord('github-user', 917672); // get a user by user id
this.get('store').findRecord('github-repository', 'jimmay5469/old-hash'); // get a repository by repository name
this.get('store').findRecord('github-repository', 34598603); // get a repository by repository id
this.get('store').query('github-branch', { repo: 'jimmay5469/old-hash' });
this.get('store').findRecord('github-branch', 'jimmay5469/old-hash/branches/master'); // get a branch
this.get('store').queryRecord('github-branch', { repo: 'jimmay5469/old-hash', branch: 'master' }); // get a specific branch
this.get('store').query('github-release', { repo: 'jimmay5469/old-hash' });
this.get('store').queryRecord('github-release', { repo: 'jimmay5469/old-hash', releaseId: 1 });
this.get('store').queryRecord('github-compare', { repo: 'jimmay5469/old-hash', base: '1234', head: '5678' });
this.get('store').query('github-pull', { repo: 'jimmay5469/old-hash' });
this.get('store').queryRecord('github-pull', { repo: 'jimmay5469/old-hash', pullId: 1 });
this.get('store').findRecord('github-organization', { org: 'my-org' });
this.get('store').query('github-members', { org: 'my-org' })
this.get('store').queryRecord('github-blob', { repo: 'jimmay5469/old-hash', sha: '47c5438403ca875f170db2aa07d1bfa3689406e3' });
this.get('store').queryRecord('github-tree', { repo: 'jimmay5469/old-hash', sha: '47c5438403ca875f170db2aa07d1bfa3689406e3' });
This addon uses ember-cli-mirage in its tests. It is often beneficial for consuming apps to be able to re-use the factories and models defined in mirage, so if you would like to use these in your tests you can add the mirage-support
object to your ember-cli-build.js
file:
module.exports = function(defaults) {
let app = new EmberApp(defaults, {
...
'mirage-support': {
includeAll: true
}
...
});
return app.toTree();
};
As long as ember-cli-mirage
is not disabled, the files in this addon's mirage-support
directory will be merged with the consuming app's namespace, and be made available to that mirage context.
The 'mirage-support'
key has 3 options:
Key | Type | Description |
---|---|---|
includeAll | Boolean | If true , includes the full mirage-support tree, i.e. no-brainer just use it all. |
exclude | {Array of GlobStrings,RegExps,Functions } | This value gets passed directly to broccoli-funnel , only if includeAll is specified. Allows for excluding certain files from import. |
include | {Array of GlobStrings,RegExps,Functions } | Passed dirctly to broccoli-funnel . Allows to pick only certain files to be imported into app namespace. |
git clone git@github.com:elwayman02/ember-data-github.git
cd ember-data-github
yarn
ember serve
npm test
(Runs ember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit https://ember-cli.com/.
FAQs
Ember Data abstraction for the GitHub API
We found that ember-data-github demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).