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

Make some OAuth2 settings optional #12258

Merged
merged 64 commits into from
Oct 8, 2024

Conversation

MarcialRosales
Copy link
Contributor

@MarcialRosales MarcialRosales commented Sep 9, 2024

Proposed Changes

Implements features:

It is accompanied by this docs PR rabbitmq/rabbitmq-website#2056

Tasks:

  • Refactor oauth2 plugin so that the core logic uses oauth_provider and resource_server types rather than asking for each setting to the deprecated config module. Split config module into oauth_provider and resource_server modules.
  • Modify oauth2 schema to include discovery_endpoint_path and discovery_endpoint_params
  • Modify management schema to include oauth_authorization_endpoint_params and oauth_token_endpoint_params
  • Modify oauth2_client so that it also accepts params in the access_token_request and discovery_endpoint to the oauth_provider type. (TODO the WSR plugin should be updated to read these extra params and pass them to the access_token_request)
  • Modify management module that generates authSettings for the ui so that it includes the new schema settings
  • Modify javascript (helper.js) so that it initilizes oidc-client-ts with the new settings
  • Verify changes against keycloak + uaa
  • Verify changes against auth0
  • Verify changes against entra
  • Verify changes against okta

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)
  • Build system and/or CI

Copy link
Member

@michaelklishin michaelklishin left a comment

Choose a reason for hiding this comment

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

@MarcialRosales we cannot use very generic modules names such as rar and oauth2, or keycloak.

We should continue using the rabbit_oauth2_ prefix in this plugin to avoid potential code path conflicts with external libraries, other plugins, and so on.

deps/rabbitmq_auth_backend_oauth2/src/resource_server.erl Outdated Show resolved Hide resolved
deps/rabbitmq_auth_backend_oauth2/src/rar.erl Outdated Show resolved Hide resolved
deps/rabbitmq_auth_backend_oauth2/src/oauth_provider.erl Outdated Show resolved Hide resolved
deps/rabbitmq_auth_backend_oauth2/src/keycloak.erl Outdated Show resolved Hide resolved
@michaelklishin
Copy link
Member

@MarcialRosales and I have agreed to move the AWS suite to use Make as part of this PR.

Improve logging
Fix an issue running selenium tests locally
WIP modify schema to configure queryParameters for
oauth2 endpoints
@MarcialRosales MarcialRosales force-pushed the make-some-oauth2-settings-optional branch from 0ac9e5f to d98eb17 Compare October 8, 2024 06:17
@michaelklishin
Copy link
Member

Erlang 27 and AWS peer discovery jobs need some work, they are not related to these changes.

lhoguin and others added 4 commits October 8, 2024 07:09
It was still possible, although rare, to have message store
files lose message data, when the following conditions were
met:

 * the message data contains byte values 255
   (255 is used as an OK marker after a message)
 * the message is located after a 0-filled hole in the file
 * the length of the data is at least 4096 bytes and
   if we misread it (as detailed below) we encounter
   a 255 byte where we expect the OK marker

The trick for the code to previously misread the length can
be explained as follow:

A message is stored in the following format:

  <<Len:64, MsgIdAndMsg:Len/unit:8, 255>>

With MsgId always being 16 bytes in length. So Len is always
at least 16, if the message data Msg is empty. But technically
it never is.

Now if we have a zero filled hole just before this message,
we may end up with this:

  <<0, Len:64, MsgIdAndMsg:Len/unit:8, 255>>

When we are scanning we are testing bytes to see if there is
a message there or not. We look for a Len that gives us byte
255 after MsgIdAndMsg.

Len of value 4096 looks like this in binary:

  <<0:48, 16, 0>>

Problem is if we have leading zeroes, Len may look like this:

  <<0, 0:48, 16, 0>>

If we take the first 64 bits we get a potential length of 16.
We look at the byte after the next 16 bytes. If it is 255, we
think this is a message and skip by this amount of bytes, and
mistakenly miss the real message.

Solving this by changing the file format would be simple enough,
but we don't have the luxury to afford that. A different solution
was found, which is to combine file scanning with checking that
the message exists in the message store index (populated from
queues at startup, and kept up to date over the life time of
the store). Then we know for sure that the message above
doesn't exist, because the MsgId won't be found in the index.
If it is, then the file number and offset will not match,
and the check will fail.

There remains a small chance that we get it wrong during dirty
recovery. Only a better file format would improve that.
@mergify mergify bot added the make label Oct 8, 2024
@michaelklishin
Copy link
Member

All suites pass on Erlang 26 and the failures on 27 are well known => merging.

@michaelklishin michaelklishin merged commit 692f299 into main Oct 8, 2024
393 of 399 checks passed
@michaelklishin michaelklishin deleted the make-some-oauth2-settings-optional branch October 8, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants