コード例 #1
0
        public HeadersAuthenticator(AuthenticatorOptionsBase options, AuthenticatorBindingOptionsBase _, ILogger <HeadersAuthenticator> logger)
        {
            _options     = options;
            _logger      = logger;
            _applicators = _options.HeaderDefinitions.Select(d =>
            {
                var applicator = new HeaderApplicator
                {
                    Definition    = d,
                    UseBasicClaim = !String.IsNullOrEmpty(d.ClaimName)
                };

                if (!applicator.UseBasicClaim)
                {
                    (var scriptOptions, var scriptText) = ParseExpression(d.Expression);
                    try
                    {
                        var script = CSharpScript.Create <string>(scriptText, scriptOptions, typeof(ExpressionGlobals));
                        applicator.ExpressionRunner = script.CreateDelegate();
                    }
                    catch (Exception ex)
                    {
                        logger.LogCritical($"Failed to compile expresion for header: {applicator.Definition.HeaderName}. {ex.Message}");
                        throw;
                    }
                }

                return(applicator);
            }).ToArray();
            _needsGlobals = _applicators.Any(a => !a.UseBasicClaim);
        }
コード例 #2
0
 public KerberosAuthenticator(AuthenticatorOptionsBase options, AuthenticatorBindingOptionsBase bindingOptions)
 {
     _options        = options;
     _bindingOptions = bindingOptions;
 }