Repository navigation
Conversation
added 2 commits
October 19, 2026 17:04
One client now reaches both the main API and the Authlete IdP, with the IdP
URL overridable for DC/self-managed deployments:
Authlete::Client.new(bearer: token, server_url: 'https://jp.authlete.com')
# services.create / remove get apiServerId 53285 automatically
Authlete::Client.new(bearer: token, server_url: 'https://authlete.example.com',
idp_url: 'https://authlete-login.example.com',
api_server_id: 99_999)
lib/authlete/idp.rb is hand-written. It installs a Faraday middleware on a
private copy of the client's connection, so a connection shared between
clients is never modified. The middleware re-points requests for the
spec-defined IdP origin at idp_url (keeping any path prefix) and fills in
apiServerId on service create and remove unless the caller set it. The ID is
derived from server_url for SaaS clusters only while the IdP is the default.
The gem entry point loads it through
.speakeasy/patches/lib/authlete_ruby_sdk.rb.patch, which Speakeasy reapplies
after every generation.
Matches the TypeScript SDK's behaviour (authlete/authlete-typescript-sdk#36).
- tests.yaml (new): on every pull request and push to main, checks that the require line from .speakeasy/patches is in the gem entry point, runs the offline tests in test/idp_routing_test.rb, and runs rubocop on the hand-written files. Robot regeneration PRs run it too, so a regeneration that lost the patch shows a failed check before merge. - sdk_publish.yaml: the same checks run first, and publishing waits for them (needs: test), so a broken SDK is never released. No secrets needed; the tests do not use the network.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets one
Authlete::Clientreach both the main API and the Authlete IdP, with the IdP URL overridable for DC/self-managed deployments. Ruby counterpart of authlete/authlete-typescript-sdk#36.Usage
How it works
lib/authlete/idp.rb(hand-written) addsidp_url:andapi_server_id:toAuthlete::Client.new.login.authlete.com) atidp_url, keeping any path prefix, and fills inapiServerIdon service create and remove unless the caller set it.apiServerIdis derived fromserver_urlfor the SaaS clusters only while the IdP is the default. With a customidp_url, it comes only fromapi_server_id..speakeasy/patches/lib/authlete_ruby_sdk.rb.patchadds onerequire_relativeto the gem entry point. Speakeasy reapplies it after every generation, so customers need no extrarequire.Testing
test/idp_routing_test.rb: 30 tests, no network. SaaS derivation for all four clusters andserver_idx, explicit and caller-supplied IDs, path prefix, port, invalid URL, main API requests unchanged, shared-connection isolation, retries injecting once, 600 concurrent requests, together with theservice_idglobal.speakeasy runs apply the patch once each time and keep the hand-written files.GEM_HOMEloads it fromrequire "authlete_ruby_sdk".CI
This adds the Ruby repo's first PR checks, so the hand-written IdP code is checked after every regeneration.
.speakeasy/patches/lib/authlete_ruby_sdk.rb.patchon every generation, including the robot's daily runs. If the patch can no longer apply, Speakeasy fails the generation instead of producing an SDK without it. No repair script of our own is needed..github/workflows/tests.yaml, new): on every pull request and push tomain, it checks that therequire_relative 'authlete/idp'line is in the gem entry point, runs the 30 offline tests, and runs rubocop on the hand-written files. Robot regeneration PRs run it too, so a regeneration that lost the patch shows a failed check before merge..github/workflows/sdk_publish.yaml): the same checks run first, and publishing waits for them (needs: test), so a broken SDK is never released to RubyGems.Verified by deleting the require line locally: the patch check failed and 25 of the 30 tests failed. No secrets are needed; the tests do not use the network.
Release
After merging, run Generate with
set_version=2.0.0to publish #25 and this change together.