Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow SameSite case insensitive binding #6101

Merged
merged 2 commits into from
Sep 6, 2021

Conversation

sdelamo
Copy link
Collaborator

@sdelamo sdelamo commented Sep 6, 2021

Close #6092

enum SameSite is:

package io.micronaut.http.cookie;

public enum SameSite {
  Lax,
  Strict,
  None;
}

I think it should have been something like:

package io.micronaut.http.cookie;

import com.fasterxml.jackson.annotation.JsonValue;

public enum SameSite {
    LAX("Lax"),
    STRICT("Strict"),
    NONE("None");

    private final String value;
    SameSite(String value) {
        this.value = value;
    }

    @JsonValue
    public String toString() {
        return this.value;
    }
}

However, changing the enum is a breaking change. Henche, I have introduced a type converter to allow for lowercase binding.

IntelliJ IDEA suggests lowercase values.

Users type a lowercase value as their IDE suggests and they are confused because it does not work.

See: micronaut-projects/micronaut-security#755

Also, test SameSite JSON rendering

Close #6092

enum `SameSite` is:

```java
package io.micronaut.http.cookie;

public enum SameSite {
  Lax,
  Strict,
  None;
}
```

I think it should have been something like:

```java
package io.micronaut.http.cookie;

import com.fasterxml.jackson.annotation.JsonValue;

public enum SameSite {
    LAX("Lax"),
    STRICT("Strict"),
    NONE("None");

    private final String value;
    SameSite(String value) {
        this.value = value;
    }

    @JsonValue
    public String toString() {
        return this.value;
    }
}
```

However, changing the enum is a breaking change. Henche, I have introduced a type converter to allow for lowercase binding.

IntelliJ IDEA suggests lowercase values.

Users type a lowercase value as their IDE suggests and they are confused because it does not work.

See: micronaut-projects/micronaut-security#755

Also, test SameSite JSON rendering
@sdelamo sdelamo added the type: bug Something isn't working label Sep 6, 2021
@jameskleeh jameskleeh merged commit 96a9353 into 3.0.x Sep 6, 2021
@jameskleeh jameskleeh deleted the same-site-three-zero-x branch September 6, 2021 13:52
sdelamo added a commit to micronaut-projects/micronaut-security that referenced this pull request Oct 7, 2021
sdelamo added a commit to micronaut-projects/micronaut-security that referenced this pull request Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binding to SameSite via configuration is case sensitive
2 participants