How to use the ember-simple-auth/authorizers/base.extend function in ember-simple-auth

To help you get started, we’ve selected a few ember-simple-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plantinformatics / pretzel / frontend / app / authorizers / application.js View on Github external
// import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer';

// export default OAuth2Bearer.extend();

import BaseAuthorizer from 'ember-simple-auth/authorizers/base'

export default BaseAuthorizer.extend({
  // serverTokenEndpoint: `${config.apiHost}/Users/login`,
  // serverTokenRevocationEndpoint: `${config.apiHost}/Users/logout`

  authorize(data, block) {
    // console.log('authorize', data, block)

    block('Authorization', data.token)
  }
});
github jpadilla / ember-simple-auth-token / addon / authorizers / token.js View on Github external
import Base from 'ember-simple-auth/authorizers/base';
import Configuration from '../configuration';

/**
  Authorizer that works with token-based authentication like JWT
  by sending the `token` properties from the session in the `Authorization` header.

  _The factory for this authorizer is registered as
  `'authorizer:token'` in Ember's container._

  @class Token
  @namespace SimpleAuth.Authorizers
  @module ember-simple-auth-token/authorizers/token
  @extends Base
*/
export default Base.extend({
  session: Ember.inject.service('session'),

  /**
    The prefix used in the value of the Authorization header.

    This value can be configured via
    [`SimpleAuth.Configuration.Token#authorizationPrefix`](#SimpleAuth-Configuration-Token-authorizationPrefix).

    @property authorizationPrefix
    @type String
    @default 'Bearer '
  */
  authorizationPrefix: 'Bearer ',

  /**
    The name of the property in session that contains token used for authorization.
github gothinkster / ember-realworld / app / authorizers / conduit.js View on Github external
import Base from 'ember-simple-auth/authorizers/base';

export default Base.extend({
  authorize(data, block) {
    const authData = data.token;
    block('Authorization', `Token ${authData}`);
  }
});
github CenterForOpenScience / ember-osf-web / app / authorizers / osf-token.js View on Github external
import Base from 'ember-simple-auth/authorizers/base';

/**
 * @module ember-osf-web
 * @submodule authorizers
 */

/**
 * Ember-simple-auth compatible authorizer based on OAuth2 bearer tokens.
 *
 * Intended to be used with the authenticator of the same name.
 *
 * @class OsfTokenAuthorizer
 * @extends ember-simple-auth/BaseAuthorizer
 */
export default Base.extend({
    authorize(sessionData, setHeader) {
        setHeader('Authorization', `Bearer ${sessionData.attributes.accessToken}`);
    },
});
github cardstack / cardstack / packages / authentication / addon / authorizers / cardstack.js View on Github external
import { get } from '@ember/object';
import { isEmpty } from '@ember/utils';
import Authorizer from 'ember-simple-auth/authorizers/base';

export default Authorizer.extend({
  authorize(rawSession, block) {
    const accessToken = get(rawSession, 'data.meta.token');

    if (!isEmpty(accessToken)) {
      block('Authorization', `Bearer ${accessToken}`);
    }
  }
});
github NREL / api-umbrella / src / api-umbrella / admin-ui / app / authorizers / devise-server-side.js View on Github external
import Base from 'ember-simple-auth/authorizers/base';

export default Base.extend({
  authorize(data, callback) {
    callback(data.api_key, data.admin_auth_token);
  },
});
github CenterForOpenScience / ember-osf / addon / authorizers / osf-token.js View on Github external
import Base from 'ember-simple-auth/authorizers/base';

/**
 * @module ember-osf
 * @submodule authorizers
 */

/**
 * Ember-simple-auth compatible authorizer based on OAuth2 bearer tokens.
 *
 * Intended to be used with the authenticator of the same name.
 *
 * @class OsfTokenAuthorizer
 * @extends ember-simple-auth/BaseAuthorizer
 */
export default Base.extend({
    authorize(sessionData, setHeader) {
        setHeader('Authorization',  `Bearer ${sessionData.attributes.accessToken}`);
    }
});
github SophieDeBenedetto / jwt-token-auth-sample-front / app / authorizers / custom.js View on Github external
import Base from 'ember-simple-auth/authorizers/base';
import Ember from 'ember';

export default Base.extend({
  session: Ember.inject.service(),
  authorize(data, block) {
    if (Ember.testing) {
      block('Authorization', 'Bearer beyonce');
    }
    const { token } = data
    if (this.get('session.isAuthenticated') && token) {
      block('Authorization', `Bearer ${token}`);
    }
  }
});
github uhuraapp / uhura-frontend / app / authorizers / uhura.js View on Github external
import Ember from 'ember';
import Base from 'ember-simple-auth/authorizers/base';

const { isEmpty } = Ember;

export default Base.extend({
  authorize(user, block) {
    if (user && user.token && !isEmpty(user.token)) {
      block('Authorization', `Token ${user.token}`);
    }
  }
});
github getslash / backslash / webapp / app / authorizers / token.js View on Github external
import { inject as service } from '@ember/service';
import Base from "ember-simple-auth/authorizers/base";

export default Base.extend({
  session: service(),
  authorize: function(jqXHR, requestOptions) {
    var session = this.get("session");
    if (!session.isAuthenticated) {
      return;
    }

    var auth_token = session.content.auth_token;
    if (requestOptions.headers === undefined) {
      requestOptions.headers = {};
    }

    requestOptions.headers["Authentication-Token"] = auth_token;
  }
});