Skip to content

Commit

Permalink
commented out breaking changes, will need major rework
Browse files Browse the repository at this point in the history
  • Loading branch information
JJBussert committed Nov 20, 2021
1 parent 5f18af8 commit 6e20a99
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions src/E13.Common.Infra/ApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace E13.Common.Infra
{
public static class ApiServiceExtensions
public static class ApiServiceExtensions
{
public static ApiService DefineApiService(this SolutionStack stack, string serviceName, Persistence includedPersistence, bool registerSwagger = true)
=> new(stack, serviceName, includedPersistence, registerSwagger);
Expand All @@ -30,8 +30,8 @@ public class ApiService
public Output<string> ApiUri { get; set; }

private readonly Output<string>? _apiSwaggerClientId;
public Output<string> ApiSwaggerClientId
{
public Output<string> ApiSwaggerClientId
{
get
{
if (_apiSwaggerClientId == null)
Expand All @@ -49,7 +49,7 @@ public ApiService(SolutionStack stack, string serviceName, Persistence included,
{
_name = $"{stack.Prefix}{serviceName}";

if(included.HasFlag(Persistence.AzureSql))
if (included.HasFlag(Persistence.AzureSql))
{
var db = new Database($"{serviceName}", new DatabaseArgs
{
Expand Down Expand Up @@ -79,7 +79,7 @@ public ApiService(SolutionStack stack, string serviceName, Persistence included,
ApiClientId = r.ApplicationId;
ApiUri = r.IdentifierUris.First();

if(registerSwagger)
if (registerSwagger)
{
var s = SwaggerRegistration(a, r);
_apiSwaggerClientId = s.ApplicationId;
Expand Down Expand Up @@ -107,13 +107,13 @@ private Application AppRegistration(AppService a)
{
var registration = new Application(_name, new ApplicationArgs
{
AvailableToOtherTenants = false,
Homepage = a.DefaultSiteHostname.Apply(host => $"https://{host}"),
//AvailableToOtherTenants = false,
//Homepage = a.DefaultSiteHostname.Apply(host => $"https://{host}"),
IdentifierUris =
{
a.Name.Apply(n => $"api://{n}"),
},
Oauth2AllowImplicitFlow = true,
//Oauth2AllowImplicitFlow = true,
// user_impresonation is automagically created so does not need to be explicitly defined
//Oauth2Permissions =
//{
Expand All @@ -132,10 +132,10 @@ private Application AppRegistration(AppService a)
{
"74c90e60-fe2b-4735-84cd-476a1c9181fb", // jj.bussert@gmail.com in e13tech
},
ReplyUrls =
{
//a.DefaultSiteHostname.Apply(host => $"https://{host}/swagger/oauth2-redirect.html"),
},
//ReplyUrls =
//{
// //a.DefaultSiteHostname.Apply(host => $"https://{host}/swagger/oauth2-redirect.html"),
//},
RequiredResourceAccesses =
{
//new Pulumi.AzureAD.Inputs.ApplicationRequiredResourceAccessArgs
Expand All @@ -151,7 +151,7 @@ private Application AppRegistration(AppService a)
// ResourceAppId = "c05e5f6b-434f-43a3-b043-a957047bf13d",
//},
},
Type = "webapp/api",
//Type = "webapp/api",
});

var sp = new ServicePrincipal(_name, new ServicePrincipalArgs
Expand All @@ -167,18 +167,18 @@ private Application SwaggerRegistration(AppService a, Application app)
var swaggerName = $"{_name}-swagger";
var registration = new Application(swaggerName, new ApplicationArgs
{
AvailableToOtherTenants = false,
Oauth2AllowImplicitFlow = true,
Homepage = a.DefaultSiteHostname.Apply(host => $"https://{host}"),
//AvailableToOtherTenants = false,
//Oauth2AllowImplicitFlow = true,
//Homepage = a.DefaultSiteHostname.Apply(host => $"https://{host}"),
Owners =
{
"74c90e60-fe2b-4735-84cd-476a1c9181fb", // jj.bussert@gmail.com in e13tech
},
ReplyUrls =
{
a.DefaultSiteHostname.Apply(host => $"https://{host}/swagger/oauth2-redirect.html"),
"https://localhost:5001/swagger/oauth2-redirect.html"
},
//ReplyUrls =
//{
// a.DefaultSiteHostname.Apply(host => $"https://{host}/swagger/oauth2-redirect.html"),
// "https://localhost:5001/swagger/oauth2-redirect.html"
//},
RequiredResourceAccesses =
{
new Pulumi.AzureAD.Inputs.ApplicationRequiredResourceAccessArgs
Expand All @@ -187,16 +187,18 @@ private Application SwaggerRegistration(AppService a, Application app)
{
new Pulumi.AzureAD.Inputs.ApplicationRequiredResourceAccessResourceAccessArgs
{
Id = app.Oauth2Permissions.Apply(p => p.First(x => x.Value == "user_impersonation").Id ?? ""),
Id = app.Oauth2PermissionScopeIds.Apply(p => p.First(x => x.Value == "user_impersonation").Key),
Type = "Scope",
},
},
ResourceAppId = app.ApplicationId.Apply(id => id),
},
},
Type = "webapp/api",
});
//Type = "webapp/api", TODO fix type?
})
{

};
var sp = new ServicePrincipal(swaggerName, new ServicePrincipalArgs
{
ApplicationId = registration.ApplicationId.Apply(i => i)
Expand Down

0 comments on commit 6e20a99

Please sign in to comment.