-
-
Notifications
You must be signed in to change notification settings - Fork 581
Add osu! to the list of supported providers #2403
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
base: dev
Are you sure you want to change the base?
Conversation
* Initial plan * Add osu! OAuth 2.0 provider to OpenIddict WebIntegration Co-authored-by: gehongyan <21241496+gehongyan@users.noreply.github.com> * Fix osu! provider: add client_credentials scope, mode parameter, remove defaults Co-authored-by: gehongyan <21241496+gehongyan@users.noreply.github.com> * Reorder osu! handlers to follow alphabetical order by ProviderTypes Co-authored-by: gehongyan <21241496+gehongyan@users.noreply.github.com> * Fix OSU! ASCII art banner to correctly spell the provider name Co-authored-by: gehongyan <21241496+gehongyan@users.noreply.github.com> * Update osu! banner and add default mode description Co-authored-by: gehongyan <21241496+gehongyan@users.noreply.github.com> * Use mode as path parameter in UserInfo endpoint URL Co-authored-by: gehongyan <21241496+gehongyan@users.noreply.github.com> * Wrap ternary expression in parentheses for C# template string Co-authored-by: gehongyan <21241496+gehongyan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gehongyan <21241496+gehongyan@users.noreply.github.com>
Docs
Hints
Note Question 1: Is it proper to force setting it in the
Note Question 2: Which naming do you prefer for parameter and constant names: GameMode, Mode, or Ruleset? For the osu!catch constant name, do you prefer Screenshots
|
|
Hey @gehongyan! Thanks for this new PR! 👏🏻
That definitely works, tho' we could also add a new dedicated That said, I see in the docs that the
Re-using the official names is generally the most reasonable approach, but if find the names currently used in your PR are clearer, I don't mind keeping them as-is 😃 Note: you'll probably want to update Thanks! |
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml
Outdated
Show resolved
Hide resolved
- Extracted OverrideScope handler - Maped WS-Federation properties - Updated XML definitions Signed-off-by: Gehongyan <gehongyan1996@126.com>
|
Hi, thanks for helping.
I’ve tested the behavior when the As shown in the screenshot below, the permission
However, I couldn't find a clean way to remove this scope if the client application specifically doesn't want to request it. Given this, should we still add it by default, or is there a specific method I missed that allows for removing default scopes? Also, it seems that the Client Credentials flow does not automatically pick up the In the meantime, assuming the
I furtherly checked how osu!web and SDKs name it.
Given that most SDKs use the names
The ID is mapped from
|
The idea behind default scopes is that they are not requested if the user explicitly added any other value (they exist because some services require at least one scope to be defined, so default scopes can be considered "fallback values").
Ah yeah, good point. You're right, the scopes configured there are only used for user-interactive flows.
Instead of setting
👍🏻 Thanks! |
Signed-off-by: Gehongyan <gehongyan1996@126.com>
I agree that. But the osu! API documentation states that identify is the default scope for the Authorization Code Grant and always implicitly provided. The Client Credentials Grant does not currently have any default scopes. Furthermore, the scope parameter is optional because when no scope is specified, osu!web only requests identify permissions (Identify you and read your public profile), and the code flow still functions correctly without any explicit scopes. In this case, do we still need to set a default value for Scope in the XML?
Thank you for the tip; However, I suddenly discovered another issue. Some scopes seemed to be only specified in the Client Credentials mode, including |
If the
Scopes registered via // Ask OpenIddict to authenticate the client application using the client credentials grant.
await _service.AuthenticateWithClientCredentialsAsync(new()
{
CancellationToken = stoppingToken,
ProviderName = provider,
Scopes = ["scope1", "scope2"]
}); |
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs
Outdated
Show resolved
Hide resolved
| if (context.GrantType is GrantTypes.ClientCredentials && | ||
| context.Registration.ProviderType is ProviderTypes.Osu) | ||
| { | ||
| context.Scopes.Add("public"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try something: try requesting one of the delegate, forum.write_manage and group_permissions scopes without adding public: if it works, it means public is not strictly required but that osu requires at least one scope to be set (what OpenIddict calls "default scope").
If it works without public being present, we may want to only add it if the context.Scopes collection is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a Chat Bot account, so I cannot request delegate or other scopes that require delegation; my personal account receives the error 'Delegation with Client Credentials is only available to chat bots.' when requesting such permissions.
However, the documentation mentions: 'When using delegation, scopes that support delegation cannot be used together with scopes that do not support delegation. Delegation is only available to Chat Bots.'
This indicates that when a developer requests delegation scopes, appending public is incorrect, because the Scopes section points out that public is not marked as Can Delegate.
The source code of osu!web also confirms this:
https://github.com/ppy/osu-web/blob/c2c9404146a934bd985d40a11a5a96fda7261338/app/Models/OAuth/Token.php#L27
https://github.com/ppy/osu-web/blob/c2c9404146a934bd985d40a11a5a96fda7261338/app/Models/OAuth/Token.php#L236-L245
In a Client Credentials request, if the scopes contain elements from SCOPES_REQUIRE_DELEGATION, all elements must be included in the SCOPES_REQUIRE_DELEGATION.
Therefore, I agree with your suggestion to add public to the context.Scopes only when it is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to create an issue on the osu!web later regarding the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…tly specified Signed-off-by: Gehongyan <gehongyan1996@126.com>
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml
Outdated
Show resolved
Hide resolved
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs
Outdated
Show resolved
Hide resolved
Signed-off-by: Gehongyan <gehongyan1996@126.com>
Signed-off-by: Gehongyan <gehongyan1996@126.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds osu! (a popular rhythm game platform) as a supported OAuth authentication provider to the OpenIddict client web integration library.
Key Changes:
- Added osu! provider configuration with OAuth 2.0 endpoints for authorization, token exchange, and user information retrieval
- Implemented custom scope handling for client credentials grant flow (defaults to "public" scope when none specified)
- Added support for optional game mode parameter in userinfo endpoint queries (osu, taiko, fruits, mania)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| OpenIddictClientWebIntegrationProviders.xml | Adds osu! provider definition with OAuth endpoints, game mode constants, and property mappings |
| OpenIddictClientWebIntegrationHandlers.cs | Implements OverrideScope handler for client credentials flow, dynamic userinfo endpoint construction with game mode support, and integrates username/user ID extraction logic |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @gehongyan, FYI: OpenIddict just moved from PolySharp to Polyfill, which allows us to use a lot more polyfills thanks to .NET 10's extensions-everything model 😃 To make sure your PR can benefit from that change, I merged the Cheers 😄 |
|
Nice work! 😄 |
|
@gehongyan do you think we can merge your PR or are there changes you'd still like to make depending on ppy/osu-web#12631 outcome? 😃 |
|
@kevinchalet |










This pull request would like to add osu! to the list of supported providers.