italia / spid-aspnetcore

AspNetCore Remote Authenticator for SPID
https://github.com/danielegiallonardo/spid-aspnetcore
MIT License
40 stars 11 forks source link

Gerarchia priorità impostazione "SecurityLevel" #57

Closed marco-maroni-spot-software closed 1 year ago

marco-maroni-spot-software commented 1 year ago

Salve quale è la gerarchia di validità del settaggio "SecurityLevel" presente sia a livello di globale, sia a livello del singolo IdP, se divergono chi comanda?

Perché vedo che pur impostando a livello globale 1, e non impostando nulla nel singolo IdP, tutti gli IdP chiedono il livello 2 nel caso del mio servizio.

Grazie mille

danielegiallonardo commented 1 year ago

Attualmente non è prevista una impostazione globale per SecurityLevel, va impostato per ogni IdP. Se non impostato, prende il livello 2 come default.

marco-maroni-spot-software commented 1 year ago

Nel codice però è gestito quel settaggio a livello globale

Dal sorgente della libreria, OptionsHelper.cs, riga 29

        internal static SpidConfiguration CreateFromConfiguration(IConfiguration configuration)
        {
            var section = configuration.GetSection("Spid");
            var options = new SpidConfiguration();

            options.IsStagingValidatorEnabled = section.GetValue<bool?>("IsStagingValidatorEnabled") ?? false;
            options.IsLocalValidatorEnabled = section.GetValue<bool?>("IsLocalValidatorEnabled") ?? false;
            options.AllowUnsolicitedLogins = section.GetValue<bool?>("AllowUnsolicitedLogins") ?? false;
            options.AssertionConsumerServiceURL = section.GetValue<string>("AssertionConsumerServiceURL");
            options.AssertionConsumerServiceIndex = section.GetValue<ushort?>("AssertionConsumerServiceIndex");
            options.AttributeConsumingServiceIndex = section.GetValue<ushort?>("AttributeConsumingServiceIndex") ?? 0;
            options.CallbackPath = section.GetValue<string>("CallbackPath");
            options.EntityId = section.GetValue<string>("EntityId");
            options.RemoteSignOutPath = section.GetValue<string>("RemoteSignOutPath");
            options.SignOutScheme = section.GetValue<string>("SignOutScheme");
            options.UseTokenLifetime = section.GetValue<bool?>("UseTokenLifetime") ?? false;
            options.SkipUnrecognizedRequests = section.GetValue<bool?>("SkipUnrecognizedRequests") ?? true;
            options.CacheIdpMetadata = section.GetValue<bool?>("CacheIdpMetadata") ?? false;
            options.RandomIdentityProvidersOrder = section.GetValue<bool?>("RandomIdentityProvidersOrder") ?? false;
            options.SecurityLevel = section.GetValue<int?>("SecurityLevel") ?? 2;

O sbaglio?

danielegiallonardo commented 1 year ago

E' un refuso, in realtà quel settaggio non viene usato. Nella versione 2.0.0 della libreria invece, in fase di validazione, questa impostazione verrà spostata a livello globale e verrà tolta a livello IdP, e sarà anche personalizzabile a runtime negli SpidEvents.