How to use the ember-get-config.authorizationType function in ember-get-config

To help you get started, we’ve selected a few ember-get-config 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 CenterForOpenScience / ember-osf / addon / mixins / generic-data-adapter.js View on Github external
ajaxOptions() {
        var hash = this._super(...arguments);

        // TODO: This mechanism is quite ugly, and will require manual ajax requests (such as the file manager) to set fields separately;
        //  getting requests to send cookies without triggering cross-origin rules would be strongly preferable
        if (config.authorizationType === 'cookie') {
            Ember.$.extend(hash, {
                xhrFields: {
                    withCredentials: true
                }
            });
        }
        return hash;
    }
});
github CenterForOpenScience / ember-osf / addon / components / dropzone-widget / component.js View on Github external
// multiple files for upload in the first place.
        if (this.get('options.preventMultipleFiles') && this.get('clickable')){
            Ember.$('.dz-hidden-input').removeAttr('multiple');
        }

        this.set('dropzoneElement', drop);

        // Set osf session header
        let headers = {};

        let authType = config['ember-simple-auth'].authorizer;
        this.get('session').authorize(authType, (headerName, content) => {
            headers[headerName] = content;
        });
        dropzoneOptions.headers = headers;
        dropzoneOptions.withCredentials = (config.authorizationType === 'cookie');

        // Attach preUpload to addedfile event
        drop.on('addedfile', file => {
            if (preUpload) {
                preUpload(this, drop, file).then(() => drop.processFile(file));
            } else {
                drop.processFile(file);
            }
        });

        // Set dropzone options
        drop.options = Ember.assign(drop.options, dropzoneOptions);

        // Attach dropzone event listeners: http://www.dropzonejs.com/#events
        drop.events.forEach(event => {
            if (typeof this.get(event) === 'function') {
github CenterForOpenScience / ember-osf-web / app / components / dropzone-widget / component.ts View on Github external
// multiple files for upload in the first place.
        if (this.get('options.preventMultipleFiles') && this.get('clickable')) {
            $('.dz-hidden-input').removeAttr('multiple');
        }

        this.set('dropzoneElement', drop);

        // Set osf session header
        const headers = {};

        this.get('session')
            .authorize(authType, (headerName, content) => Object.assign(headers, { [headerName]: content }));

        Object.assign(dropzoneOptions, {
            headers,
            withCredentials: config.authorizationType === 'cookie',
        });

        // Attach preUpload to addedfile event
        drop.on('addedfile', async file => {
            if (preUpload) {
                await preUpload(this, drop, file);
            }

            drop.processFile(file);
        });

        // Set dropzone options
        Object.assign(drop.options, dropzoneOptions);

        // Attach dropzone event listeners: http://www.dropzonejs.com/#events
        drop.events.forEach(event => {
github CenterForOpenScience / ember-osf-web / app / mixins / generic-data-adapter.ts View on Github external
import Mixin from '@ember/object/mixin';
import config from 'ember-get-config';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
import $ from 'jquery';

const isCookieAuth = config.authorizationType === 'cookie';

/**
 * Extend the Ember-Simple-Auth adapter to provide cookie support (when necessary).
 * This allows the same addon to define an adapter that works with two authentication types.
 *
 * This particularly applies to local development, as without it cookies are not sent from the ember app to the api
 * domain
 *
 * @class GenericDataADapter
 */
export default Mixin.create(DataAdapterMixin, {
    ajaxOptions(...args: any[]): object {
        const hash: object = this._super(...args);

        // TODO: This mechanism is quite ugly, and will require manual ajax requests (such as the file manager) to set
        // fields separately; getting requests to send cookies without triggering cross-origin rules would be strongly
github CenterForOpenScience / ember-osf / addon / mixins / osf-agnostic-auth-route.js View on Github external
import Ember from 'ember';
import config from 'ember-get-config';

import OsfTokenLoginRoute from '../mixins/osf-token-login-route';
import OsfCookieLoginRoute from '../mixins/osf-cookie-login-route';

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

var AuthMixin;

let authType = config.authorizationType;
if (authType === 'token') {
    AuthMixin = OsfTokenLoginRoute;
} else if (authType === 'cookie') {
    AuthMixin = OsfCookieLoginRoute;
} else {
    throw new Ember.Error(`Unrecognized authorization type: ${authType}`);
}
/**
 * Route mixin for authentication-agnostic login: defines the application at runtime to use the authentication method
 *   specified in environment config. Intended to be used in tandem with OsfAgnosticAuthRoute mixin.
 * Some authentication methods (eg cookies) are not available to third-party applications.
 * This has limited use, since most applications will only need to support one method. It may be useful for ember apps
 *   that run inside the OSF, eg to use the standalone dev server, or to offer support for branded apps
 *   on third-party domains.
 *
 * @class OsfAgnosticAuthRoute
github CenterForOpenScience / ember-osf-web / app / mixins / osf-agnostic-auth-route.js View on Github external
import EmberError from '@ember/error';
import config from 'ember-get-config';

import OsfTokenLoginRoute from '../mixins/osf-token-login-route';
import OsfCookieLoginRoute from '../mixins/osf-cookie-login-route';

/**
 * @module ember-osf-web
 * @submodule mixins
 */
const authType = config.authorizationType;
if (authType !== 'token' && authType !== 'cookie') {
    throw new EmberError(`Unrecognized authorization type: ${authType}`);
}

const AuthMixin = authType === 'token' ? OsfTokenLoginRoute : OsfCookieLoginRoute;
/**
 * Route mixin for authentication-agnostic login: defines the application at runtime to use the authentication method
 *   specified in environment config. Intended to be used in tandem with OsfAgnosticAuthRoute mixin.
 * Some authentication methods (eg cookies) are not available to third-party applications.
 * This has limited use, since most applications will only need to support one method. It may be useful for ember apps
 *   that run inside the OSF, eg to use the standalone dev server, or to offer support for branded apps
 *   on third-party domains.
 *
 * @class OsfAgnosticAuthRoute
 * @extends Ember.Mixin
 * @uses ember-osf-web/OsfCookieLoginRoute
github CenterForOpenScience / ember-osf / addon / utils / ajax-helpers.js View on Github external
function authenticatedAJAX(options) {
    if (config.authorizationType === 'cookie') {
        Ember.merge(options, {
            xhrFields: {
                withCredentials: true
            }
        });
    }
    return Ember.$.ajax(options);

}
export { authenticatedAJAX };
github CenterForOpenScience / ember-osf / addon / mixins / osf-agnostic-auth-controller.js View on Github external
import Ember from 'ember';
import config from 'ember-get-config';

import OsfTokenLoginController from '../mixins/osf-token-login-controller';
import OsfCookieLoginController from '../mixins/osf-cookie-login-controller';

/**
 * @module ember-osf
 * @submodule mixins
 */
var AuthMixin;

let authType = config.authorizationType;
if (authType === 'token') {
    AuthMixin = OsfTokenLoginController;
} else if (authType === 'cookie') {
    AuthMixin = OsfCookieLoginController;
} else {
    throw new Ember.Error(`Unrecognized authorization type: ${authType}`);
}
/**
 * Controller mixin for authentication-agnostic login: defines the application at runtime to use the authentication method
 *   specified in environment config. Intended to be used in tandem with OsfAuthController mixin.
 * Some authentication methods (eg cookies) are not available to third-party applications.
 * This has limited use, since most applications will only need to support one method. It may be useful for ember apps
 *   that run inside the OSF, eg to use the standalone dev server, or to offer support for branded apps
 *   on third-party domains.
 *
 * @class OsfAgnosticAuthController
github CenterForOpenScience / ember-osf / addon / utils / auth.js View on Github external
function getAuthUrl() {
    let authType = config.authorizationType;
    if (authType === 'token') {
        return getOAuthUrl(...arguments);
    } else if (authType === 'cookie') {
        return getCookieAuthUrl(...arguments);
    } else {
        throw new Ember.Error(`Unrecognized authorization type: ${authType}`);
    }
}
github CenterForOpenScience / ember-osf / addon / services / current-user.js View on Github external
authenticatedAJAX(options, addApiHeaders = true) {
        const opts = Ember.assign({}, options);

        if (config.authorizationType === 'cookie') {
            opts.xhrFields = Ember.assign({
                    withCredentials: true
                }, opts.xhrFields || {});
        }

        if (addApiHeaders) {
            opts.headers = Ember.assign({}, this.ajaxHeaders(), opts.headers || {});
        }

        return Ember.$.ajax(opts);
    },