Base solution for your next web application

Activities of "Bernard"

//MS Graph Authentification services.AddAuthentication().AddMicrosoftIdentityWebApp(configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(configuration.GetValue<string>("DownstreamApi:Scopes")?.Split(' ')) .AddMicrosoftGraph(configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches();

Same issue

I follow your example like :

  var authenticationBuilder = services.AddAuthentication();

  if (bool.Parse(configuration["Authentication:OpenId:IsEnabled"]))
  {
      if (bool.Parse(configuration["Authentication:AllowSocialLoginSettingsPerTenant"]))
      {
          services.AddSingleton&lt;IOptionsMonitor&lt;OpenIdConnectOptions&gt;, TenantBasedOpenIdConnectOptions>();
      }

      authenticationBuilder.AddOpenIdConnect(options =>
      {
          options.ClientId = configuration["Authentication:OpenId:ClientId"];
          options.Authority = configuration["Authentication:OpenId:Authority"];
          options.SignedOutRedirectUri = configuration["App:WebSiteRootAddress"] + "Account/Logout";
          options.ResponseType = configuration["Authentication:OpenId:ResponseType"];

          options.TokenValidationParameters = new TokenValidationParameters()
          {
              ValidateIssuer = bool.Parse(configuration["Authentication:OpenId:ValidateIssuer"])
          };

          options.Events.OnTokenValidated = context =>
          {
              var jsonClaimMappings = new List&lt;JsonClaimMap&gt;();
              configuration.GetSection("Authentication:OpenId:ClaimsMapping").Bind(jsonClaimMappings);

              context.AddMappedClaims(jsonClaimMappings);

              return Task.FromResult(0);
          };

          var clientSecret = configuration["Authentication:OpenId:ClientSecret"];
          if (!clientSecret.IsNullOrEmpty())
          {
              options.ClientSecret = clientSecret;
          }
      });

  };


  authenticationBuilder.AddMicrosoftIdentityWebApp(configuration.GetSection("AzureAd"))
  .EnableTokenAcquisitionToCallDownstreamApi(configuration.GetValue&lt;string&gt;("DownstreamApi:Scopes")?.Split(' '))
      .AddMicrosoftGraph(configuration.GetSection("DownstreamApi"))
      .AddInMemoryTokenCaches();
      

but it cause issue

An error occurred while starting the application. InvalidOperationException: Scheme already exists: OpenIdConnect

Microsoft.AspNetCore.Authentication.AuthenticationOptions.AddScheme(string name, Action<AuthenticationSchemeBuilder> configureBuilder) ComponentActivatorException: ComponentActivator: could not instantiate Microsoft.AspNetCore.Authentication.AuthenticationSchemeProvider

Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, object[] arguments, Type implType)

InvalidOperationException: Scheme already exists: OpenIdConnect
    Microsoft.AspNetCore.Authentication.AuthenticationOptions.AddScheme(string name, Action&lt;AuthenticationSchemeBuilder&gt; configureBuilder)
    Microsoft.Extensions.Options.OptionsFactory&lt;TOptions&gt;.Create(string name)
    Microsoft.Extensions.Options.UnnamedOptionsManager&lt;TOptions&gt;.get_Value()
    Microsoft.AspNetCore.Authentication.AuthenticationSchemeProvider..ctor(IOptions&lt;AuthenticationOptions&gt; options, IDictionary&lt;string, AuthenticationScheme&gt; schemes)
    lambda_method47(Closure , object[] )
    Castle.Core.Internal.ReflectionUtil.Instantiate(ConstructorInfo ctor, object[] ctorArgs)
    Castle.Core.Internal.ReflectionUtil.Instantiate&lt;TBase&gt;(Type subtypeofTBase, object[] ctorArgs)
    Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, object[] arguments, Type implType)

Hi

No, I not able to call AddMicrosoftIdentityWebApp And Openconnect because each uses the same scheme

Hi,

Any idea ? For having 2 schemes when Connecting ?

I think it should be something like this : https://stackoverflow.com/questions/49694383/use-multiple-jwt-bearer-authentication but for Openconnect

Answer

Hi ismail,

Thks

Hi I send you detail by email did you receive it ?

Hi

I see it support but you must change manifest and workaround security So I prefer keep manually

Thanks

Hi,

After changing this value

var emailClaim = claims.FirstOrDefault(c => c.Type == "unique_name"); to

var emailClaim = claims.FirstOrDefault(c => c.Type == "preferred_username");

Everything works well

But i think we **must always **add the tenant subdomain manually to make the openconnectId work ?

  • wildcard is not allowed *

Hi,

I would like to save it also.

Like

I’d like to display the good control combobox Date String I think on looping with switch case on type

 @foreach (var item in Model.DynamicProperties)
 {
 <div class="mb-5">
     <label for="edp-create-modal-dynamicPropertyId" class="form-label">@item.PropertyName</label>
         @switch (item.InputType.Name)
    {

        case "COMBOBOX" :
                            // code block
          break;

        case "SINGLE_LINE_STRING":
                             // code block
          break;

         case "DATETIME":
                            // code block
            break;


    }

 </div>

Sorry, but what are the arguments ?

private readonly IDynamicEntityPropertyValueAppService _dynamicValues; var listdynamic = _dynamicValues.GetAllDynamicEntityPropertyValues(Person);??

Should the service be called in a Js view like CreateorEdit.js for my entity an example would be welcome

I tried with this method in PersonController :

``[AbpMvcAuthorize(AppPermissions.Pages_Contacts_Create, AppPermissions.Pages_Contacts_Create)]
public async Task<ActionResult> CreateOrEdit(int? id)
{
    GetPersonForEditOutput getPersonForEditOutput;

    if (id.HasValue)
    {
        getPersonForEditOutput = await _personsAppService.GetPersonForEdit(new EntityDto { Id = (int)id });
      

    }
    else
    {
        getPersonForEditOutput = new GetPersonForEditOutput
        {
            Person = new CreateOrEditPersonDto()
        };

        getPersonForEditOutput.Person.Intitule = "A DEFINIR";
        getPersonForEditOutput.Person.Source = ListSource.BackOffice;
        getPersonForEditOutput.Person.Statut = ListeStatutPerson.ColdLead;
        getPersonForEditOutput.Person.DateNaissance = DateTime.Now;

    }

    getPersonForEditOutput.Person.TypePerson = TypePerson.Physique;
    getPersonForEditOutput.Person.ProfilPhysique = ListeProfilPhysique.Contact;


    var allDynamicProperties = (await _dynamicPropertyAppService.GetAll()).Items.ToList();
    var definedPropertyIds = (await _dynamicEntityPropertyAppService.GetAllPropertiesOfAnEntity(new DynamicEntityPropertyGetAllInput() { EntityFullName = "Person" }))
        .Items.Select(x => x.DynamicPropertyId).ToList();

    var viewModel = new CreateOrEditPersonViewModel()
    {
        Person = getPersonForEditOutput.Person,
        PersonIntitule = getPersonForEditOutput.PersonIntitule,
        DynamicProperties = allDynamicProperties.Where(x => !definedPropertyIds.Contains(x.Id)).ToList()
};

    return View(viewModel);
}

Is it right ? I don't know how display Values in View

Showing 51 to 60 of 92 entries