@ovh-ux/ng-ovh-sso-auth

4.8.1 • Public • Published

ng-ovh-sso-auth

OVH $http interceptor working with SSO. Can be used with $resource!

npm version Downloads Dependencies Dev Dependencies

Install

$ yarn add @ovh-ux/ng-ovh-sso-auth

Usage

import angular from 'angular';
import ngOvhSsoAuth from '@ovh-ux/ng-ovh-sso-auth';

angular
  .module('myApp', [ngOvhSsoAuth])
  .config(
    /* @ngInject */ ($httpProvider, constants, ssoAuthenticationProvider) => {
      ssoAuthenticationProvider.setLoginUrl(
        constants.prodMode ? constants.loginUrl : 'auth.html',
      );

      ssoAuthenticationProvider.setLogoutUrl(
        constants.prodMode
          ? '/engine/api/auth/logout'
          : 'api/proxypass/auth/logout',
      );

      ssoAuthenticationProvider.setUserUrl(
        constants.prodMode ? '/engine/api/me' : 'api/user',
      );

      const configuration = [
        {
          serviceType: 'api',
          urlPrefix: 'api',
        },
        {
          serviceType: 'aapi',
          urlPrefix: constants.prodMode ? '../2api-m' : '2api-m',
        },
        {
          serviceType: 'apiv6',
          urlPrefix: 'apiv6',
        },
      ];

      ssoAuthenticationProvider.setConfig(configuration);

      $httpProvider.interceptors.push('OvhSsoAuthInterceptor');
    },
  )
  .run(
    /* @ngInject */ (ssoAuthentication) => {
      ssoAuthentication.login().then(() => {
        // Do what you want after login.
      });
    },
  );

Test

$ yarn test

Related

Contributing

Always feel free to help out! Whether it's filing bugs and feature requests or working on some of the open issues, our contributing guide will help get you started.

License

BSD-3-Clause © OVH SAS

Package Sidebar

Install

npm i @ovh-ux/ng-ovh-sso-auth

Weekly Downloads

20

Version

4.8.1

License

BSD-3-Clause

Unpacked Size

180 kB

Total Files

14

Last publish

Collaborators

  • jisay
  • blary_jp
  • antleblanc
  • cbourgois
  • ovh-ux-cds
  • lizardk
  • ovh
  • marie-j