Skip to content

[ECO-4845] Fix wildcard clientId - #418

Merged
sacOO7 merged 6 commits into
feature/integration-protocol-2from
fix/wildcard-clientId-request
Jul 4, 2024
Merged

[ECO-4845] Fix wildcard clientId #418
sacOO7 merged 6 commits into
feature/integration-protocol-2from
fix/wildcard-clientId-request

Conversation

@sacOO7

@sacOO7sacOO7 commented Jun 25, 2024

Copy link
Copy Markdown
Contributor

Fixed#414

  1. Added client_id_for_request method
  2. Added method client_id_for_request_sync to realtime auth
  3. Annotated implementation with right spec

1. Renamed rest auth extra_auth_headers to client_id_header with both rest/realtime specific impl
2. Added method client_id_header_sync to realtime auth
3. Annotated implementation with right spec
@github-actions
github-actionsBottemporarily deployed to staging/pull/418/features June 25, 2024 10:29 Inactive
@sacOO7sacOO7 changed the title [ECO-4845] Refactored rest/realtime auth[ECO-4845] Fix wildcard clientId Jun 25, 2024
@github-actions
github-actionsBottemporarily deployed to staging/pull/418/docs June 25, 2024 10:29 Inactive
Comment threadlib/ably/auth.rb Outdated
def client_id_header(realtime=false)
if options[:client_id] && using_basic_auth?
if realtime
{ 'clientId' => options[:client_id] }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For realtime connections the clientId is passed in the query params, not as a header - see RSA7e1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think by putting the realtime setting in a method that explicitly mentions header (even if its later put in the right place by subsequent code) is going to make things confusing

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yeah, it's just a naming convention. I will try to make it more meaningful 👍

@sacOO7sacOO7Jun 25, 2024

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

As far as spec impl. is concerned, setting clientId for both realtime and rest follows exactly similar checks
spec- RSA7e

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated -> bb4b71f

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

maybe custom_client_id or external_client_id

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

updated -> 0f49ede

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, perhaps we should just have a method which returns the client id to use in the request:

defclient_id_for_requestifoptions[:client_id] && using_basic_auth?returnoptions[:client_id]elsereturnnilendend

and we update the existing extra_auth_headers method to call this, and update create_websocket_transport to call it?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed 1ff7d6b

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool, looks good to me — will leave to @AndyTWF to resolve if happy since it's his thread

@github-actions
github-actionsBottemporarily deployed to staging/pull/418/features June 25, 2024 10:43 Inactive
@github-actions
github-actionsBottemporarily deployed to staging/pull/418/docs June 25, 2024 10:43 Inactive
@sacOO7
sacOO7 requested a review from AndyTWFJune 25, 2024 10:44
@github-actions
github-actionsBottemporarily deployed to staging/pull/418/features June 25, 2024 10:53 Inactive
@github-actions
github-actionsBottemporarily deployed to staging/pull/418/docs June 25, 2024 10:54 Inactive
@github-actions
github-actionsBottemporarily deployed to staging/pull/418/features June 25, 2024 10:59 Inactive
@github-actions
github-actionsBottemporarily deployed to staging/pull/418/docs June 25, 2024 10:59 Inactive
@sacOO7
sacOO7 requested review from ttypic and removed request for ttypicJuly 2, 2024 10:21
@lawrence-forooghian

Copy link
Copy Markdown
Contributor

@sacOO7 is this a bug that only affects the v2 branch? If not, then shouldn't the fix go into main so that we can release it ASAP?

@ttypic

Copy link
Copy Markdown
Contributor

@lawrence-forooghian there is no rush, this problem have been for a long time. Workaround on realtime side implemented for all version <= 1.2.5

@sacOO7

sacOO7 commented Jul 2, 2024

Copy link
Copy Markdown
ContributorAuthor

@sacOO7 is this a bug that only affects the v2 branch? If not, then shouldn't the fix go into main so that we can release it ASAP?

Actually, this bug was caused by server side changes, so they have patched a fix that will work for ably-ruby <= 1.2.5
Link to internal conversation for more information -> https://ably-real-time.slack.com/archives/C8SPU4589/p1718885475429199

Comment threadlib/ably/auth.rb
Comment threadlib/ably/realtime/connection.rb Outdated
Comment threadlib/ably/realtime/presence/members_map.rb Outdated
Comment threadlib/ably/auth.rb Outdated
def client_id_header(realtime=false)
if options[:client_id] && using_basic_auth?
if realtime
{ 'clientId' => options[:client_id] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, perhaps we should just have a method which returns the client id to use in the request:

defclient_id_for_requestifoptions[:client_id] && using_basic_auth?returnoptions[:client_id]elsereturnnilendend

and we update the existing extra_auth_headers method to call this, and update create_websocket_transport to call it?

Base automatically changed from feature/protocol-2-presence to feature/integration-protocol-2July 3, 2024 11:50

@ttypicttypic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@sacOO7

Copy link
Copy Markdown
ContributorAuthor

Thanks for the review

@sacOO7
sacOO7 merged commit 08877bf into feature/integration-protocol-2Jul 4, 2024
@sacOO7
sacOO7 deleted the fix/wildcard-clientId-request branch July 4, 2024 18:30
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@sacOO7@lawrence-forooghian@ttypic@AndyTWF