Sha256: 0a2644dc668bb8b06b78fc4a9249f6bde9bbec2cd50f3170ab3cd9ca741efb8b

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 KB

Contents

## Cookies

SecureHeaders supports `Secure`, `HttpOnly` and [`SameSite`](https://tools.ietf.org/html/draft-west-first-party-cookies-07) cookies. These can be defined in the form of a boolean, or as a Hash for more refined configuration.

__Note__: Regardless of the configuration specified, Secure cookies are only enabled for HTTPS requests.

#### Boolean-based configuration

Boolean-based configuration is intended to globally enable or disable a specific cookie attribute.

```ruby
config.cookies = {
  secure: true, # mark all cookies as Secure
  httponly: false, # do not mark any cookies as HttpOnly
}
```

#### Hash-based configuration

Hash-based configuration allows for fine-grained control.

```ruby
config.cookies = {
  secure: { except: ['_guest'] }, # mark all but the `_guest` cookie as Secure
  httponly: { only: ['_rails_session'] }, # only mark the `_rails_session` cookie as HttpOnly
}
```

#### SameSite cookie configuration

SameSite cookies permit either `Strict` or `Lax` enforcement mode options.

```ruby
config.cookies = {
  samesite: {
    strict: true # mark all cookies as SameSite=Strict
  }
}
```

`Strict` and `Lax` enforcement modes can also be specified using a Hash.

```ruby
config.cookies = {
  samesite: {
    strict: { only: ['_rails_session'] },
    lax: { only: ['_guest'] }
  }
}
```

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
secure_headers-3.7.3 docs/cookies.md
secure_headers-3.7.2 docs/cookies.md
secure_headers-3.7.1 docs/cookies.md
secure_headers-3.7.0 docs/cookies.md
secure_headers-3.6.7 docs/cookies.md
secure_headers-3.6.6 docs/cookies.md
secure_headers-3.6.5 docs/cookies.md
secure_headers-3.6.4 docs/cookies.md
secure_headers-3.6.3 docs/cookies.md
secure_headers-3.6.2 docs/cookies.md
secure_headers-3.6.1 docs/cookies.md
secure_headers-3.6.0 docs/cookies.md