Exemple #1
0
        protected RequestBase(AuthenticationRequestParameters authenticationRequestParameters)
        {
            TokenCache = authenticationRequestParameters.TokenCache;

            authenticationRequestParameters.RequestContext.Logger.Info(string.Format(CultureInfo.InvariantCulture,
                                                                                     "=== Token Acquisition ({4}) started:\n\tAuthority: {0}\n\tScope: {1}\n\tClientId: {2}\n\tCache Provided: {3}",
                                                                                     authenticationRequestParameters?.Authority?.CanonicalAuthority,
                                                                                     authenticationRequestParameters.Scope.AsSingleString(),
                                                                                     authenticationRequestParameters.ClientId,
                                                                                     TokenCache != null, this.GetType().Name));

            AuthenticationRequestParameters = authenticationRequestParameters;
            if (authenticationRequestParameters.Scope == null || authenticationRequestParameters.Scope.Count == 0)
            {
                throw new ArgumentNullException(nameof(authenticationRequestParameters.Scope));
            }

            ValidateScopeInput(authenticationRequestParameters.Scope);
            LoadFromCache = (TokenCache != null);
            StoreToCache  = (TokenCache != null);
            SupportADFS   = false;

            AuthenticationRequestParameters.LogState();
            Client.Telemetry.GetInstance().ClientId = AuthenticationRequestParameters.ClientId;
        }
        protected RequestBase(AuthenticationRequestParameters authenticationRequestParameters)
        {
            TokenCache = authenticationRequestParameters.TokenCache;

            // Log contains Pii
            authenticationRequestParameters.RequestContext.Logger.InfoPii(string.Format(CultureInfo.InvariantCulture,
                                                                                        "=== Token Acquisition ({4}) started:\n\tAuthority: {0}\n\tScope: {1}\n\tClientId: {2}\n\tCache Provided: {3}",
                                                                                        authenticationRequestParameters?.Authority?.CanonicalAuthority,
                                                                                        authenticationRequestParameters.Scope.AsSingleString(),
                                                                                        authenticationRequestParameters.ClientId,
                                                                                        TokenCache != null, this.GetType().Name));

            // Log does not contain Pii
            var msg = string.Format(CultureInfo.InvariantCulture,
                                    "=== Token Acquisition ({1}) started:\n\tCache Provided: {0}", TokenCache != null, this.GetType().Name);

            if (authenticationRequestParameters.Authority != null &&
                AadAuthority.IsInTrustedHostList(authenticationRequestParameters.Authority.Host))
            {
                msg += string.Format(CultureInfo.CurrentCulture, "\n\tAuthority Host: {0}",
                                     authenticationRequestParameters.Authority.Host);
            }
            authenticationRequestParameters.RequestContext.Logger.Info(msg);

            AuthenticationRequestParameters = authenticationRequestParameters;
            if (authenticationRequestParameters.Scope == null || authenticationRequestParameters.Scope.Count == 0)
            {
                throw new ArgumentNullException(nameof(authenticationRequestParameters.Scope));
            }

            ValidateScopeInput(authenticationRequestParameters.Scope);
            LoadFromCache = (TokenCache != null);
            StoreToCache  = (TokenCache != null);
            SupportADFS   = false;

            AuthenticationRequestParameters.LogState();
            Client.Telemetry.GetInstance().ClientId = AuthenticationRequestParameters.ClientId;
        }