Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Created option for RequireHttpsAttribute.Permanent #5026

Merged
merged 8 commits into from
Aug 4, 2016
Merged

Created option for RequireHttpsAttribute.Permanent #5026

merged 8 commits into from
Aug 4, 2016

Conversation

iscifoni
Copy link
Contributor

Created an option for RequireHttpsAttribute.Permanent
#4650

@dnfclas
Copy link

dnfclas commented Jul 15, 2016

Hi @iscifoni, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

/// </summary>
public RequireHttpsAttribute()
{
this.Permanent = null;
Copy link
Contributor

@khellang khellang Jul 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assignment is redundant. Why even have these constructors (including the one with the parameter)? When I added the Permanent property, I left them out intentionally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectively the assignment is redundant, and also the contructor, I have use it to do debug.
I remove it.

- RequireHttpsAttribute modify permanent
public bool Permanent {
get
{
return _permanent ?? false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: one-liners?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when i use it to mark a controller or action an error occurs when specify a value , is not a valid attribute parameter type because is nullable value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that you could collapse the getter and setter:

public bool Permanent
{
    get { return _permanent ?? false; }
    set { _permanent = value; }
}

😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry 😄 😄

/// Gets or sets the default value for Permanent property of <see cref="RequireHttpsAttribute"/>.
/// </summary>
public bool RequireHttpsPermanent { get; set; }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: extra blank line

@khellang
Copy link
Contributor

Left some comments on minor style nits, not sure how strongly the team feels about those 😝

@iscifoni
Copy link
Contributor Author

Ok thanks for your observations 😄

@khellang
Copy link
Contributor

Awesome ❤️

@@ -140,5 +140,10 @@ public int MaxModelValidationErrors
/// is used. If not set the port won't be specified in the secured URL e.g. https://localhost/path.
/// </summary>
public int? SslPort { get; set; }

/// <summary>
/// Gets or sets the default value for Permanent property of <see cref="RequireHttpsAttribute"/>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to: ... for *the* Permanent...

@Eilon
Copy link
Member

Eilon commented Jul 26, 2016

@iscifoni thanks for sending the PR! And @khellang thanks for doing the code review!

I've added a few other small comments, and I assigned to @sebastienros for final review and to merge.

@@ -82,6 +88,9 @@ protected virtual void HandleNonHttpsRequest(AuthorizationFilterContext filterCo
host = new HostString(host.Host);
}

//i use MvcOption.requireHttpsPermanent value if Permanent parameter is null
_permanent = _permanent ?? optionsAccessor.Value.RequireHttpsPermanent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thought about one thing... Should this be assigned back to the field, or should we keep falling back to optionsAccessor.Value.RequireHttpsPermanent for each call? Can the option change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the options don't change, i can use a new field but it will have the value from optionsAccessor.Value.RequireHttpsPermanent for each call...

Copy link
Contributor

@khellang khellang Jul 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's functionality for reloading configuration (i.e. when a config file changes). Whether that also propagates into options (bound to configuration), I'm not sure about.

Also, changing this exact value at runtime makes little sense to me. I just thought it was worth asking 😄

Anyway, I don't think a new field is necessary. A variable would probably do it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would indeed just use a variable to store the result of the computation. I didn't notice that it sets the property - that's not good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And yes, there is such a thing as reloadable configuration and options, but MVC doesn't use it, so that isn't an actual concern here.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok i will use a variabile instead of property

@sebastienros
Copy link
Member

:shipit:

@sebastienros sebastienros merged commit be5deef into aspnet:dev Aug 4, 2016
@Eilon
Copy link
Member

Eilon commented Aug 4, 2016

@iscifoni thanks for the PR!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants