Skip to content

Commit

Permalink
Rename cleanup
Browse files Browse the repository at this point in the history
- Classes should mostly be named Saml2XXX and not SustainsysSaml2XXX
- Casing for config section
- Owin dictionary key for idp selection.
  • Loading branch information
AndersAbel committed Jan 15, 2018
1 parent ae288e7 commit 2e5648d
Show file tree
Hide file tree
Showing 26 changed files with 243 additions and 244 deletions.
2 changes: 1 addition & 1 deletion CustomDictionary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Word>Auth</Word>
<Word>Authn</Word>
<Word>AuthnRequest</Word>
<Word>Sustainsys</Word>
<Word>Kentor</Word>
<Word>Sustainsys</Word>
<Word>Idp</Word>
<Word>Mvc</Word>
Expand Down
6 changes: 3 additions & 3 deletions Samples/SampleHttpModuleApplication/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="Sustainsys.Saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
<section name="sustainsys.saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
</configSections>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
Expand Down Expand Up @@ -41,7 +41,7 @@
<add name="Saml2AuthenticationModule" type="Sustainsys.Saml2.HttpModule.Saml2AuthenticationModule, Sustainsys.Saml2.HttpModule" />
</modules>
</system.webServer>
<Sustainsys.Saml2 entityId="http://localhost:17009/SamplePath/Saml2" returnUrl="http://localhost:17009/SamplePath/" discoveryServiceUrl="http://localhost:52071/DiscoveryService"
<sustainsys.saml2 entityId="http://localhost:17009/SamplePath/Saml2" returnUrl="http://localhost:17009/SamplePath/" discoveryServiceUrl="http://localhost:52071/DiscoveryService"
authenticateRequestSigningBehavior="Always">
<nameIdPolicy allowCreate="true" format="Persistent" />
<requestedAuthnContext classRef="Password" comparison="Minimum" />
Expand All @@ -56,7 +56,7 @@
<serviceCertificates>
<add fileName="~/App_Data/Sustainsys.Saml2.Tests.pfx" />
</serviceCertificates>
</Sustainsys.Saml2>
</sustainsys.saml2>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" name="SampleApplicationAuth"/>
Expand Down
6 changes: 3 additions & 3 deletions Samples/SampleIdentityServer3/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void Configuration(IAppBuilder app)
private void ConfigureSaml2(IAppBuilder app, string signInAsType)
{

var options = new SustainsysSaml2AuthenticationOptions(false)
var options = new Saml2AuthenticationOptions(false)
{
SPOptions = new SPOptions
{
Expand All @@ -150,10 +150,10 @@ private void ConfigureSaml2(IAppBuilder app, string signInAsType)
LoadMetadata = true
});

app.UseSustainsysSaml2Authentication(options);
app.UseSaml2Authentication(options);
}

private void UseIdSrv3LogoutOnFederatedLogout(IAppBuilder app, SustainsysSaml2AuthenticationOptions options)
private void UseIdSrv3LogoutOnFederatedLogout(IAppBuilder app, Saml2AuthenticationOptions options)
{
app.Map("/signoutcleanup", cleanup =>
{
Expand Down
6 changes: 3 additions & 3 deletions Samples/SampleMvcApplication/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="Sustainsys.Saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
<section name="sustainsys.saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
</configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
Expand All @@ -31,7 +31,7 @@
</modules>

</system.webServer>
<Sustainsys.Saml2 entityId="http://localhost:2181/Saml2" returnUrl="http://localhost:2181/" discoveryServiceUrl="http://localhost:52071/DiscoveryService">
<sustainsys.saml2 entityId="http://localhost:2181/Saml2" returnUrl="http://localhost:2181/" discoveryServiceUrl="http://localhost:52071/DiscoveryService">
<identityProviders>
<add entityId="https://stubidp.sustainsys.com/Metadata"
signOnUrl="https://stubidp.sustainsys.com/"
Expand All @@ -45,7 +45,7 @@
<serviceCertificates>
<add fileName="~/App_Data/Sustainsys.Saml2.Tests.pfx" />
</serviceCertificates>
</Sustainsys.Saml2>
</sustainsys.saml2>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" name="SampleMvcApplicationAuth" />
Expand Down
6 changes: 3 additions & 3 deletions Samples/SampleOwinApplication/App_Start/Startup.Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public void ConfigureAuth(IAppBuilder app)
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

app.UseSustainsysSaml2Authentication(CreateSaml2Options());
app.UseSaml2Authentication(CreateSaml2Options());
}

private static SustainsysSaml2AuthenticationOptions CreateSaml2Options()
private static Saml2AuthenticationOptions CreateSaml2Options()
{
var spOptions = CreateSPOptions();
var Saml2Options = new SustainsysSaml2AuthenticationOptions(false)
var Saml2Options = new Saml2AuthenticationOptions(false)
{
SPOptions = spOptions
};
Expand Down
4 changes: 2 additions & 2 deletions Sustainsys.Saml2.AspNetCore2/Saml2Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Saml2Options()
/// Set of callbacks that can be used as extension points for various
/// events.
/// </summary>
public SustainsysSaml2Notifications Notifications { get; }
= new SustainsysSaml2Notifications();
public Saml2Notifications Notifications { get; }
= new Saml2Notifications();
}
}
2 changes: 1 addition & 1 deletion Sustainsys.Saml2.Owin/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Sustainsys.Saml2.Owin
{
static class Constants
{
public const string DefaultAuthenticationType = "SustainsysSaml2";
public const string DefaultAuthenticationType = "Saml2";
public const string DefaultCaption = "SAML2 Federation";
}
}
8 changes: 4 additions & 4 deletions Sustainsys.Saml2.Owin/Saml2AuthenticationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ namespace Owin
/// <summary>
/// Extension method to easily attach Sustainsys Saml2 to the Owin pipeline.
/// </summary>
public static class SustainsysSaml2AuthenticationExtensions
public static class Saml2AuthenticationExtensions
{
/// <summary>
/// Add Sustainsys Saml2 SAML2 authentication to the Owin pipeline.
/// </summary>
/// <param name="app">Owin pipeline builder.</param>
/// <param name="options">Options for the middleware.</param>
/// <returns></returns>
public static IAppBuilder UseSustainsysSaml2Authentication(this IAppBuilder app,
SustainsysSaml2AuthenticationOptions options)
public static IAppBuilder UseSaml2Authentication(this IAppBuilder app,
Saml2AuthenticationOptions options)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}

app.Use(typeof(SustainsysSaml2AuthenticationMiddleware), app, options);
app.Use(typeof(Saml2AuthenticationMiddleware), app, options);

return app;
}
Expand Down
4 changes: 2 additions & 2 deletions Sustainsys.Saml2.Owin/Saml2AuthenticationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Sustainsys.Saml2.Owin
{
class SustainsysSaml2AuthenticationHandler : AuthenticationHandler<SustainsysSaml2AuthenticationOptions>
class Saml2AuthenticationHandler : AuthenticationHandler<Saml2AuthenticationOptions>
{
protected async override Task<AuthenticationTicket> AuthenticateCoreAsync()
{
Expand Down Expand Up @@ -120,7 +120,7 @@ protected override async Task ApplyResponseChallengeAsync()
else
{
object objIdp = null;
Context.Environment.TryGetValue("SustainsysSaml2.idp", out objIdp);
Context.Environment.TryGetValue("saml2.idp", out objIdp);
idp = objIdp as EntityId;
}
var redirectUri = challenge.Properties.RedirectUri;
Expand Down
16 changes: 8 additions & 8 deletions Sustainsys.Saml2.Owin/Saml2AuthenticationMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace Sustainsys.Saml2.Owin
/// <summary>
/// Owin middleware for SAML2 authentication.
/// </summary>
public class SustainsysSaml2AuthenticationMiddleware
: AuthenticationMiddleware<SustainsysSaml2AuthenticationOptions>
public class Saml2AuthenticationMiddleware
: AuthenticationMiddleware<Saml2AuthenticationOptions>
{
/// <summary>
/// Constructor
Expand All @@ -29,10 +29,10 @@ public class SustainsysSaml2AuthenticationMiddleware
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Justification = "options is validated by base ctor. Test case for null options giving ArgumentNullException works.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "SPOptions")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "EntityId")]
public SustainsysSaml2AuthenticationMiddleware(
public Saml2AuthenticationMiddleware(
OwinMiddleware next,
IAppBuilder app,
SustainsysSaml2AuthenticationOptions options)
Saml2AuthenticationOptions options)
:base (next, options)
{
if(app == null)
Expand All @@ -56,21 +56,21 @@ public SustainsysSaml2AuthenticationMiddleware(
}

options.DataProtector = app.CreateDataProtector(
typeof(SustainsysSaml2AuthenticationMiddleware).FullName);
typeof(Saml2AuthenticationMiddleware).FullName);

if(options.SPOptions.Logger == null)
{
options.SPOptions.Logger = new OwinLoggerAdapter(app.CreateLogger<SustainsysSaml2AuthenticationMiddleware>());
options.SPOptions.Logger = new OwinLoggerAdapter(app.CreateLogger<Saml2AuthenticationMiddleware>());
}
}

/// <summary>
/// Creates a handler instance for use when processing a request.
/// </summary>
/// <returns>Handler instance.</returns>
protected override AuthenticationHandler<SustainsysSaml2AuthenticationOptions> CreateHandler()
protected override AuthenticationHandler<Saml2AuthenticationOptions> CreateHandler()
{
return new SustainsysSaml2AuthenticationHandler();
return new Saml2AuthenticationHandler();
}
}
}
8 changes: 4 additions & 4 deletions Sustainsys.Saml2.Owin/Saml2AuthenticationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ namespace Sustainsys.Saml2.Owin
/// <summary>
/// Options for Sustainsys Saml2 Saml2 Authentication.
/// </summary>
public class SustainsysSaml2AuthenticationOptions : AuthenticationOptions, IOptions
public class Saml2AuthenticationOptions : AuthenticationOptions, IOptions
{
/// <summary>
/// Set of callbacks that can be used as extension points for various
/// events.
/// </summary>
public SustainsysSaml2Notifications Notifications { get; set; }
public Saml2Notifications Notifications { get; set; }

/// <summary>
/// Constructor
/// <param name="loadConfiguration">Should the options be inited by loading app/web.config?</param>
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "SustainsysSaml2")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Microsoft.Owin.Security.AuthenticationDescription.set_Caption(System.String)")]
public SustainsysSaml2AuthenticationOptions(bool loadConfiguration)
public Saml2AuthenticationOptions(bool loadConfiguration)
: base(Constants.DefaultAuthenticationType)
{
AuthenticationMode = AuthenticationMode.Passive;
Description.Caption = Constants.DefaultCaption;
Notifications = new SustainsysSaml2Notifications();
Notifications = new Saml2Notifications();

if (loadConfiguration)
{
Expand Down
1 change: 0 additions & 1 deletion Sustainsys.Saml2.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
CodeCoverage.runsettings = CodeCoverage.runsettings
CONTRIBUTING.md = CONTRIBUTING.md
CONTRIBUTORS.txt = CONTRIBUTORS.txt
LICENSE = LICENSE
README.md = README.md
Sustainsys.Saml2.ruleset = Sustainsys.Saml2.ruleset
Expand Down
2 changes: 1 addition & 1 deletion Sustainsys.Saml2/Configuration/IOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public interface IOptions
/// Set of callbacks that can be used as extension points for various
/// events.
/// </summary>
SustainsysSaml2Notifications Notifications { get; }
Saml2Notifications Notifications { get; }
}
}
4 changes: 2 additions & 2 deletions Sustainsys.Saml2/Configuration/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Options : IOptions
/// Set of callbacks that can be used as extension points for various
/// events.
/// </summary>
public SustainsysSaml2Notifications Notifications { get; set; }
public Saml2Notifications Notifications { get; set; }

/// <summary>
/// Reads the options from the current config file.
Expand Down Expand Up @@ -48,7 +48,7 @@ private static Options LoadOptionsFromConfiguration()
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "sp")]
public Options(SPOptions spOptions)
{
Notifications = new SustainsysSaml2Notifications();
Notifications = new Saml2Notifications();
SPOptions = spOptions;
if(SPOptions.Logger == null)
{
Expand Down
4 changes: 2 additions & 2 deletions Sustainsys.Saml2/Configuration/Saml2Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace Sustainsys.Saml2.Configuration
/// Set of callbacks that can be used as extension points for various
/// events.
/// </summary>
public class SustainsysSaml2Notifications
public class Saml2Notifications
{
/// <summary>
/// Ctor, setting all callbacks to do-nothing versions.
/// </summary>
public SustainsysSaml2Notifications()
public Saml2Notifications()
{
AuthenticationRequestCreated = (request, provider, dictionary) => { };
SignInCommandResultCreated = (cr, r) => { };
Expand Down
2 changes: 1 addition & 1 deletion Sustainsys.Saml2/WebSSO/AcsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Saml2 will redirect the client to the configured ReturnUrl after
In code-based config, add a ReturnUrl by setting the
options.SpOptions.ReturnUrl property. In the config file, set the returnUrl
attribute of the <Sustainsys.Saml2> element.";
attribute of the <sustainsys.saml2> element.";

internal const string SpInitiatedMissingReturnUrl =
@"Successfully received and validated response from Idp, but don't know
Expand Down
6 changes: 3 additions & 3 deletions Tests/HttpModule.Tests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<configuration>
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="Sustainsys.Saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
<section name="sustainsys.saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
</configSections>
<Sustainsys.Saml2 entityId="https://github.com/SustainsysIT/Saml2">
<sustainsys.saml2 entityId="https://github.com/SustainsysIT/Saml2">
<identityProviders>
<add entityId="https://idp.example.com"
signOnUrl="https://idp.example.com/idp"
Expand All @@ -17,5 +17,5 @@
</artifactResolutionServices>
</add>
</identityProviders>
</Sustainsys.Saml2>
</sustainsys.saml2>
</configuration>
6 changes: 3 additions & 3 deletions Tests/Mvc.Tests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<configuration>
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="Sustainsys.Saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
<section name="sustainsys.saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
</configSections>
<Sustainsys.Saml2 entityId="https://github.com/SustainsysIT/Saml2">
<sustainsys.saml2 entityId="https://github.com/SustainsysIT/Saml2">
<serviceCertificates>
<add fileName="Sustainsys.Saml2.Tests2.pfx" />
</serviceCertificates>
Expand Down Expand Up @@ -35,7 +35,7 @@
<signingCertificate fileName="Sustainsys.Saml2.Tests.pfx" />
</add>
</identityProviders>
</Sustainsys.Saml2>
</sustainsys.saml2>
<system.identityModel>
<identityConfiguration saveBootstrapContext="true">
<claimsAuthenticationManager type="Sustainsys.Saml2.TestHelpers.ClaimsAuthenticationManagerStub, TestHelpers" />
Expand Down
6 changes: 3 additions & 3 deletions Tests/Owin.Tests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="Sustainsys.Saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
<section name="sustainsys.saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
</configSections>
<Sustainsys.Saml2 entityId="https://github.com/SustainsysIT/Saml2"
<sustainsys.saml2 entityId="https://github.com/SustainsysIT/Saml2"
returnUrl="http://localhost/LoggedIn">
<serviceCertificates>
<add fileName="Sustainsys.Saml2.Tests2.pfx" />
Expand Down Expand Up @@ -40,7 +40,7 @@
<federations>
<add metadataLocation="federation.xml" allowUnsolicitedAuthnResponse="true" />
</federations>
</Sustainsys.Saml2>
</sustainsys.saml2>
<system.identityModel>
<identityConfiguration saveBootstrapContext="true">
<claimsAuthenticationManager type="Sustainsys.Saml2.TestHelpers.ClaimsAuthenticationManagerStub, TestHelpers" />
Expand Down
6 changes: 3 additions & 3 deletions Tests/Owin.Tests/OwinStubFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ namespace Sustainsys.Saml2.Owin.Tests
{
class OwinStubFactory
{
internal static SustainsysSaml2AuthenticationOptions CreateOwinOptions()
internal static Saml2AuthenticationOptions CreateOwinOptions()
{
return (SustainsysSaml2AuthenticationOptions)StubFactory.CreateOptions(
sp => new SustainsysSaml2AuthenticationOptions(false)
return (Saml2AuthenticationOptions)StubFactory.CreateOptions(
sp => new Saml2AuthenticationOptions(false)
{
SPOptions = sp,
SignInAsAuthenticationType = "AuthType",
Expand Down
Loading

0 comments on commit 2e5648d

Please sign in to comment.