Ejemplo n.º 1
0
 public AuthenticationController(IAuthenticationCommand authenticationCommand,
                                 IAuthenticationQuery authenticationQuery,
                                 IOrganizationMembershipManagementQuery organizationMembershipManagementQuery)
 {
     _authenticationCommand = authenticationCommand;
     _authenticationQuery   = authenticationQuery;
     _organizationMembershipManagementQuery = organizationMembershipManagementQuery;
 }
Ejemplo n.º 2
0
 public AuthenticacionService(IAuthenticationQuery query)
 {
     _query = query;
 }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options => options.ModelValidatorProviders.Clear()).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title   = "My API",
                    Version = "v1"
                });

                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);

                c.IncludeXmlComments(xmlPath);
                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    In          = ParameterLocation.Header,
                    Description = "Please insert JWT with Bearer into field",
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.ApiKey
                });
                c.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            }
                        },
                        new string[] { }
                    }
                });
            });

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddFromConfigurationFile(Configuration.GetSection("Services"));

            ServiceProvider            serviceProvider           = services.BuildServiceProvider();
            IAuthenticationCommand     authenticationCommand     = serviceProvider.GetService <IAuthenticationCommand>();
            IAuthenticationQuery       authenticationQuery       = serviceProvider.GetService <IAuthenticationQuery>();
            IAuthenticationInformation authenticationInformation = serviceProvider.GetService <IAuthenticationInformation>();

            services.AddControllers(config =>
            {
                config.Filters.Add(new AuthenticationFilter(authenticationInformation, authenticationCommand, authenticationQuery));
                config.Filters.Add(new ActionFilterExample());
            });

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new UserManagementMappingProfile());
                mc.AddProfile(new CustomerManagementMappingProfile());
                mc.AddProfile(new OrganizationManagementMappingProfile());
                mc.AddProfile(new OrganizationMembershipManagementMappingProfile());
            });

            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);
        }
Ejemplo n.º 4
0
 public AuthenticationFilter(IAuthenticationInformation authenticationInformation, IAuthenticationCommand authenticationCommand, IAuthenticationQuery authenticationQuery)
 {
     _authenticationCommand     = authenticationCommand;
     _authenticationQuery       = authenticationQuery;
     _authenticationInformation = authenticationInformation;
 }