adal.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * @copyright
  3. * Copyright © Microsoft Open Technologies, Inc.
  4. *
  5. * All Rights Reserved
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http: *www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
  14. * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
  15. * ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A
  16. * PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT.
  17. *
  18. * See the Apache License, Version 2.0 for the specific language
  19. * governing permissions and limitations under the License.
  20. */
  21. 'use strict';
  22. var _ = require('underscore');
  23. var ac = require('./authentication-context');
  24. var authParams = require('./authentication-parameters');
  25. var logging = require('./log');
  26. var MemoryCache = require('./memory-cache');
  27. exports = {};
  28. exports.Logging = logging.Logging;
  29. exports.AuthenticationContext = ac.AuthenticationContext;
  30. exports.setGlobalADALOptions = ac.setGlobalADALOptions;
  31. exports.getGlobalADALOptions = ac.getGlobalADALOptions;
  32. exports.MemoryCache = MemoryCache;
  33. _.extend(exports, authParams);
  34. /**
  35. * Creates a new AuthenticationContext object. By default the authority will be checked against
  36. * a list of known Azure Active Directory authorities. If the authority is not recognized as
  37. * one of these well known authorities then token acquisition will fail. This behavior can be
  38. * turned off via the validateAuthority parameter below.
  39. * @function
  40. * @param {string} authority A URL that identifies a token authority.
  41. * @param {bool} [validateAuthority] Turns authority validation on or off. This parameter default to true.
  42. * @returns {AuthenticationContext} A new authentication context.
  43. */
  44. exports.createAuthenticationContext = function(authority, validateAuthority) {
  45. return new ac.AuthenticationContext(authority, validateAuthority);
  46. };
  47. module.exports = exports;