Skip to content

Conversation

@skycocker
Copy link
Contributor

Addresses #122.

@skycocker skycocker changed the title (#122) Make the state parameter verification optional Make the state parameter verification optional Oct 27, 2022
@skycocker skycocker force-pushed the 122-ms-optional_state branch from 82ca2a2 to bbe06b6 Compare October 27, 2022 11:16
error = params['error_reason'] || params['error']
error_description = params['error_description'] || params['error_reason']
invalid_state = params['state'].to_s.empty? || params['state'] != stored_state
invalid_state = options.verify_state && (params['state'].to_s.empty? || params['state'] != stored_state)
Copy link

@syakovyn syakovyn Oct 27, 2022

Choose a reason for hiding this comment

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

I'd not exclude state mismatch from the check. Only a case when there is no state stored and no state passed.
Maybe change it to:

(options.require_state && params['state'].to_s.empty?) || params['state'] != stored_state

and use require_state instead of verfiy_state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair - made the changes.

@skycocker skycocker force-pushed the 122-ms-optional_state branch from bbe06b6 to 19b1c3d Compare October 27, 2022 14:58
@stanhu
Copy link
Contributor

stanhu commented Nov 18, 2022

Can you rebase master?

@stanhu
Copy link
Contributor

stanhu commented Nov 21, 2022

There are also Rubocop failures in https://github.com/omniauth/omniauth_openid_connect/actions/runs/3338515447/jobs/5862634541.

@skycocker skycocker force-pushed the 122-ms-optional_state branch from 19b1c3d to de13bcf Compare November 21, 2022 15:47
@skycocker skycocker force-pushed the 122-ms-optional_state branch from de13bcf to 96de262 Compare November 21, 2022 15:50
@skycocker
Copy link
Contributor Author

Addressed.

@skycocker skycocker requested a review from syakovyn November 21, 2022 16:01
CHANGELOG.md Outdated
@@ -1,3 +1,7 @@
# v0.4.1 (06.02.2022)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably create an UNRELEASED section, and update this after the official release has been cut.

omniauth#132
refactored the test so that nonce is automatically generated.
@stanhu stanhu merged commit 445805b into omniauth:master Nov 29, 2022
stanhu added a commit that referenced this pull request Jun 27, 2024
In #127,
`require_state` was introduced because according to
https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.1,
`state` is recommended but not required:

```
state
    RECOMMENDED. Opaque value used to maintain state between the
    request and the callback. Typically, Cross-Site Request Forgery
    (CSRF, XSRF) mitigation is done by cryptographically binding the
    value of this parameter with a browser cookie.
```

During review, the `require_state` parameter was modified to verify
`state` as long as `stored_state` was present. However, `stored_state`
always holds at least a random value, so when `require_state` were
`false` and if an OpenID provider did not relay the `state` value,
authentication would halt with a "Invalid 'state' parameter" error.

This commit updates it so that if `require_state` is set to `false`,
the `state` parameter is never checked at all.
stanhu added a commit that referenced this pull request Jun 27, 2024
In #127,
`require_state` was introduced because according to
https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.1,
`state` is recommended but not required:

```
state
    RECOMMENDED. Opaque value used to maintain state between the
    request and the callback. Typically, Cross-Site Request Forgery
    (CSRF, XSRF) mitigation is done by cryptographically binding the
    value of this parameter with a browser cookie.
```

During review, the `require_state` parameter was modified to verify
`state` as long as `stored_state` was present. However, `stored_state`
always holds at least a random value, so when `require_state` were
`false` and if an OpenID provider did not relay the `state` value,
authentication would halt with a "Invalid 'state' parameter" error.

This commit updates it so that if `require_state` is set to `false`,
the `state` parameter is never checked at all.
stanhu added a commit that referenced this pull request Jun 27, 2024
In #127,
`require_state` was introduced because according to
https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.1,
`state` is recommended but not required:

```
state
    RECOMMENDED. Opaque value used to maintain state between the
    request and the callback. Typically, Cross-Site Request Forgery
    (CSRF, XSRF) mitigation is done by cryptographically binding the
    value of this parameter with a browser cookie.
```

During review, the `require_state` parameter was modified to verify
`state` as long as `stored_state` was present. However, `stored_state`
always holds at least a random value, so when `require_state` were
`false` and if an OpenID provider did not relay the `state` value,
authentication would halt with a "Invalid 'state' parameter" error.

This commit updates it so that if `require_state` is set to `false`,
the `state` parameter is never checked at all.
bufferoverflow pushed a commit that referenced this pull request Jun 28, 2024
In #127,
`require_state` was introduced because according to
https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.1,
`state` is recommended but not required:

```
state
    RECOMMENDED. Opaque value used to maintain state between the
    request and the callback. Typically, Cross-Site Request Forgery
    (CSRF, XSRF) mitigation is done by cryptographically binding the
    value of this parameter with a browser cookie.
```

During review, the `require_state` parameter was modified to verify
`state` as long as `stored_state` was present. However, `stored_state`
always holds at least a random value, so when `require_state` were
`false` and if an OpenID provider did not relay the `state` value,
authentication would halt with a "Invalid 'state' parameter" error.

This commit updates it so that if `require_state` is set to `false`,
the `state` parameter is never checked at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants