-
Notifications
You must be signed in to change notification settings - Fork 598
logging, added tests, fixed code only flow. #202
Changes from all commits
f17921c
4ea3ebe
e4b4150
efaef89
75fbec3
5f923a5
df0701f
4b22fe0
1d8bb77
b7d3252
a599e14
05f2410
162f588
670437e
f1fa19b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,31 +52,30 @@ public OpenIdConnectAuthenticationOptions() | |
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationOptions.set_Caption(System.String)", Justification = "Not a LOC field")] | ||
public OpenIdConnectAuthenticationOptions(string authenticationScheme) | ||
{ | ||
// REVIEW: why was this active by default?? | ||
//AuthenticationMode = AuthenticationMode.Active; | ||
AuthenticationScheme = authenticationScheme; | ||
BackchannelTimeout = TimeSpan.FromMinutes(1); | ||
Caption = OpenIdConnectAuthenticationDefaults.Caption; | ||
ProtocolValidator = new OpenIdConnectProtocolValidator(); | ||
RefreshOnIssuerKeyNotFound = true; | ||
ResponseMode = OpenIdConnectResponseModes.FormPost; | ||
ResponseType = OpenIdConnectResponseTypes.CodeIdToken; | ||
Scope = OpenIdConnectScopes.OpenIdProfile; | ||
TokenValidationParameters = new TokenValidationParameters(); | ||
UseTokenLifetime = true; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the Authority to use when making OpenIdConnect calls. | ||
/// Gets or sets the expected audience for any received JWT token. | ||
/// </summary> | ||
public string Authority { get; set; } | ||
/// <value> | ||
/// The expected audience for any received JWT token. | ||
/// </value> | ||
public string Audience { get; set; } | ||
|
||
/// <summary> | ||
/// An optional constrained path on which to process the authentication callback. | ||
/// If not provided and RedirectUri is available, this value will be generated from RedirectUri. | ||
/// Gets or sets the Authority to use when making OpenIdConnect calls. | ||
/// </summary> | ||
/// <remarks>If you set this value, then the <see cref="OpenIdConnectAuthenticationHandler"/> will only listen for posts at this address. | ||
/// If the IdentityProvider does not post to this address, you may end up in a 401 -> IdentityProvider -> Client -> 401 -> ...</remarks> | ||
public PathString CallbackPath { get; set; } | ||
public string Authority { get; set; } | ||
|
||
#if DNX451 | ||
/// <summary> | ||
|
@@ -112,7 +111,7 @@ public TimeSpan BackchannelTimeout | |
{ | ||
if (value <= TimeSpan.Zero) | ||
{ | ||
throw new ArgumentOutOfRangeException("BackchannelTimeout", value, Resources.ArgsException_BackchallelLessThanZero); | ||
throw new ArgumentOutOfRangeException("BackchannelTimeout", value, Resources.OIDCH_0101_BackChallnelLessThanZero); | ||
} | ||
|
||
_backchannelTimeout = value; | ||
|
@@ -128,6 +127,14 @@ public string Caption | |
set { Description.Caption = value; } | ||
} | ||
|
||
/// <summary> | ||
/// An optional constrained path on which to process the authentication callback. | ||
/// If not provided and RedirectUri is available, this value will be generated from RedirectUri. | ||
/// </summary> | ||
/// <remarks>If you set this value, then the <see cref="OpenIdConnectAuthenticationHandler"/> will only listen for posts at this address. | ||
/// If the IdentityProvider does not post to this address, you may end up in a 401 -> IdentityProvider -> Client -> 401 -> ...</remarks> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heh? 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure what you are asking? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just saying that this remark is not totally clear 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then make a suggestion. |
||
public PathString CallbackPath { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the 'client_id'. | ||
/// </summary> | ||
|
@@ -145,36 +152,28 @@ public string Caption | |
public OpenIdConnectConfiguration Configuration { get; set; } | ||
|
||
/// <summary> | ||
/// The OpenIdConnect protocol http://openid.net/specs/openid-connect-core-1_0.html | ||
/// recommends adding a nonce to a request as a mitigation against replay attacks when requesting id_tokens. | ||
/// By default the runtime uses cookies with unique names generated from a hash of the nonce. | ||
/// </summary> | ||
public INonceCache NonceCache { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the discovery endpoint for obtaining metadata | ||
/// Responsible for retrieving, caching, and refreshing the configuration from metadata. | ||
/// If not provided, then one will be created using the MetadataAddress and Backchannel properties. | ||
/// </summary> | ||
public string MetadataAddress { get; set; } | ||
public IConfigurationManager<OpenIdConnectConfiguration> ConfigurationManager { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the expected audience for any received JWT token. | ||
/// Gets or sets a value controlling if the 'CurrentUri' should be used as the 'local redirect' post authentication | ||
/// if AuthenticationProperties.RedirectUri is null or empty. | ||
/// </summary> | ||
/// <value> | ||
/// The expected audience for any received JWT token. | ||
/// </value> | ||
public string Audience { get; set; } | ||
public bool DefaultToCurrentUriOnRedirect { get; set; } | ||
|
||
/// <summary> | ||
/// Responsible for retrieving, caching, and refreshing the configuration from metadata. | ||
/// If not provided, then one will be created using the MetadataAddress and Backchannel properties. | ||
/// Gets or sets the discovery endpoint for obtaining metadata | ||
/// </summary> | ||
public IConfigurationManager<OpenIdConnectConfiguration> ConfigurationManager { get; set; } | ||
public string MetadataAddress { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets if a metadata refresh should be attempted after a SecurityTokenSignatureKeyNotFoundException. This allows for automatic | ||
/// recovery in the event of a signature key rollover. This is enabled by default. | ||
/// The OpenIdConnect protocol http://openid.net/specs/openid-connect-core-1_0.html | ||
/// recommends adding a nonce to a request as a mitigation against replay attacks when requesting id_tokens. | ||
/// By default the runtime uses cookies with unique names generated from a hash of the nonce. | ||
/// </summary> | ||
public bool RefreshOnIssuerKeyNotFound { get; set; } | ||
public INonceCache NonceCache { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the <see cref="OpenIdConnectAuthenticationNotifications"/> to notify when processing OpenIdConnect messages. | ||
|
@@ -217,11 +216,22 @@ public OpenIdConnectProtocolValidator ProtocolValidator | |
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "By Design")] | ||
public string RedirectUri { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets if a metadata refresh should be attempted after a SecurityTokenSignatureKeyNotFoundException. This allows for automatic | ||
/// recovery in the event of a signature key rollover. This is enabled by default. | ||
/// </summary> | ||
public bool RefreshOnIssuerKeyNotFound { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the 'resource'. | ||
/// </summary> | ||
public string Resource { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the 'response_mode'. | ||
/// </summary> | ||
public string ResponseMode { get; private set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm definitely not sure that exposing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, but you can get it. If you want it changed, open an issue. |
||
|
||
/// <summary> | ||
/// Gets or sets the 'response_type'. | ||
/// </summary> | ||
|
@@ -233,10 +243,7 @@ public OpenIdConnectProtocolValidator ProtocolValidator | |
public string Scope { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the authentication scheme corresponding to the middleware | ||
/// responsible of persisting user's identity after a successful authentication. | ||
/// This value typically corresponds to a cookie middleware registered in the Startup class. | ||
/// When omitted, <see cref="ExternalAuthenticationOptions.SignInScheme"/> is used as a fallback value. | ||
/// Gets or sets the SignInScheme which will be used to set the <see cref="System.Security.Claims.ClaimsIdentity.AuthenticationType"/>. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is not clear and should mention that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want the comment short and not link it to another middleware that may or may not be present. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In most cases, it will be present, because the OIDC (just like the other social middleware) doesn't issue any cookie: persistence is always delegated to another middleware. And BTW, you SHOULDN'T set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't have to mention specifically cookie middleware, but it would be good to have more detail given that this is one of the more critical properties which will break everything if misconfigured There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we figure out what to say, we will make a change. |
||
/// </summary> | ||
public string SignInScheme { get; set; } | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered replacing this interface by
IDistributedCache
?https://github.com/aspnet/Caching/blob/dev/src/Microsoft.Framework.Caching.Distributed/IDistributedCache.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't. Feel free to open an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: #212