Skip to content

Commit

Permalink
Merge pull request #11 from openimis/v1.0.0
Browse files Browse the repository at this point in the history
V1.0.0
  • Loading branch information
dragos-dobre authored Nov 26, 2018
2 parents b32d737 + e3c5bb6 commit 4ef8774
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions OpenImis.RestApi/Controllers/FamilyControllerV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OpenImis.Modules;
Expand All @@ -16,6 +17,7 @@ namespace OpenImis.RestApi.Controllers
[Authorize(Roles = "IMISAdmin, EnrollmentOfficer")]
[Route("api/family")]
[ApiController]
[EnableCors("AllowSpecificOrigin")]
public class FamilyControllerV1 : Controller
{
private readonly IImisModules _imisModules;
Expand Down
2 changes: 2 additions & 0 deletions OpenImis.RestApi/Controllers/LocationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OpenImis.Modules;
Expand All @@ -16,6 +17,7 @@ namespace OpenImis.RestApi.Controllers
[Authorize(Roles = "IMISAdmin, EnrollmentOfficer")]
[Route("api/location")]
[ApiController]
[EnableCors("AllowSpecificOrigin")]
public class LocationController : Controller
{
private readonly IImisModules _imisModules;
Expand Down
5 changes: 4 additions & 1 deletion OpenImis.RestApi/Controllers/LoginControllerV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
using OpenImis.Modules;
using System.ComponentModel.DataAnnotations;
using OpenImis.Modules.UserModule.Entities;
using Microsoft.AspNetCore.Cors;

namespace OpenImis.RestApi.Controllers
{
[ApiVersion("1")]
[Route("api/login")]
[ApiController]
public class LoginControllerV1 : ControllerBase
[EnableCors("AllowSpecificOrigin")]

public class LoginControllerV1 : ControllerBase
{
private readonly IConfiguration _configuration;
private readonly IImisModules _imisModules;
Expand Down
2 changes: 2 additions & 0 deletions OpenImis.RestApi/Controllers/MasterDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OpenImis.Modules;
Expand All @@ -14,6 +15,7 @@ namespace OpenImis.RestApi.Controllers
[Authorize(Roles = "IMISAdmin, EnrollmentOfficer")]
[Route("api/master")]
[ApiController]
[EnableCors("AllowSpecificOrigin")]
public class MasterDataController : Controller
{
private readonly IImisModules _imisModules;
Expand Down
2 changes: 2 additions & 0 deletions OpenImis.RestApi/Controllers/ValuesControllerV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;

namespace OpenImis.RestApi.Controllers
{
[ApiVersion("1")]
[Route("api/values")]
[ApiController]
[EnableCors("AllowSpecificOrigin")]
public class ValuesControllerV1 : Controller
{
// GET api/values
Expand Down
8 changes: 8 additions & 0 deletions OpenImis.RestApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -66,6 +67,11 @@ public void ConfigureServices(IServiceCollection services)

services.AddSwaggerGen(SwaggerHelper.ConfigureSwaggerGen);

services.AddCors(options =>
{
options.AddPolicy("AllowSpecificOrigin",
builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowCredentials().AllowAnyHeader());
});
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
Expand All @@ -86,6 +92,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
app.UseAuthentication();
app.UseMvc();

app.UseCors("AllowSpecificOrigin");


// ===== Create tables ======
//imisContext.Database.EnsureCreated();
Expand Down

0 comments on commit 4ef8774

Please sign in to comment.