-
-
Notifications
You must be signed in to change notification settings - Fork 740
Add Apple Sign-In response_mode=form_post support #1385
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
Draft
Copilot
wants to merge
9
commits into
main
Choose a base branch
from
copilot/add-apple-signin-response-mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2293acd
Initial plan
Copilot b787d1a
Initial analysis of Apple Sign-In OAuth issue
Copilot b740042
Add Apple Sign-In response_mode=form_post support
Copilot 0bc3cb3
Add POST form_post support for OAuth callback and tests
Copilot 301da3c
Address code review feedback
Copilot 7e91379
Merge branch 'main' into copilot/add-apple-signin-response-mode
mattwoberts 6e0210b
Revert .test.env to original state
Copilot 63f274f
Merge branch 'main' into copilot/add-apple-signin-response-mode
mattwoberts a221b7d
Merge branch 'main' into copilot/add-apple-signin-response-mode
mattwoberts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,37 @@ | ||
| package oauth | ||
|
|
||
| import "net/url" | ||
| import ( | ||
| "net/url" | ||
| "strings" | ||
|
|
||
| "github.com/getfider/fider/app/models/entity" | ||
| ) | ||
|
|
||
| var providerParams = map[string]map[string]string{ | ||
| "id.twitch.tv": { | ||
| "claims": `{"userinfo":{"preferred_username":null,"email":null,"email_verified":null}}`, | ||
| }, | ||
| } | ||
|
|
||
| func getProviderInitialParams(u *url.URL) url.Values { | ||
| func getProviderInitialParams(u *url.URL, config *entity.OAuthConfig) url.Values { | ||
| v := url.Values{} | ||
| if params, ok := providerParams[u.Hostname()]; ok { | ||
| hostname := u.Hostname() | ||
|
|
||
| // Add static provider-specific parameters | ||
| if params, ok := providerParams[hostname]; ok { | ||
| for key, value := range params { | ||
| v.Add(key, value) | ||
| } | ||
| } | ||
|
|
||
| // Add dynamic parameters based on provider and scope | ||
| // Apple Sign-In requires response_mode=form_post when name or email scopes are requested | ||
| if hostname == "appleid.apple.com" && config != nil { | ||
| scope := strings.ToLower(config.Scope) | ||
| if strings.Contains(scope, "name") || strings.Contains(scope, "email") { | ||
| v.Add("response_mode", "form_post") | ||
| } | ||
| } | ||
|
|
||
| return v | ||
| } | ||
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
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
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
Oops, something went wrong.
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.
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.
Is this something that will be required from other oauth providers in the future, and if so should we make it configurable, or is it unlikey?
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.
The approach is designed to be extensible. Currently, Apple is the only known provider requiring dynamic parameters based on scope. The implementation handles both:
providerParamsmap (like Twitch's claims parameter)If other providers need similar dynamic behavior in the future, the pattern is already established - just add another hostname check with the appropriate logic. Making it fully configurable (e.g., via database or config file) would add complexity without a clear use case yet.