-
-
Notifications
You must be signed in to change notification settings - Fork 766
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
2293acd
b787d1a
b740042
0bc3cb3
301da3c
7e91379
6e0210b
63f274f
a221b7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,35 @@ | ||
| GO_ENV=test | ||
| LOG_LEVEL=DEBUG | ||
| HOST_MODE=multi | ||
| DATABASE_URL=postgres://fider_test:fider_test_pw@localhost:5566/fider_test?sslmode=disable | ||
| HOST_DOMAIN=test.fider.io | ||
| BASE_URL=https://test.fider.io:3000 | ||
| JWT_SECRET=SOME_RANDOM_TOKEN_JUST_FOR_TESTING | ||
|
|
||
| METRICS_ENABLED=true | ||
| BASE_URL=http://localhost:3000 | ||
| GO_ENV=development | ||
| DATABASE_URL=postgres://fider:fider_pw@localhost:5555/fider?sslmode=disable | ||
| JWT_SECRET=hsjl]W;&ZcHxT&FK;s%bgIQF:#ch=~#Al4:5]N;7V<qPZ3e9lT4'%;go;LIkc%k | ||
| # ALLOW_ALLOWED_SCHEMES=false | ||
|
|
||
| POST_CREATION_WITH_TAGS_ENABLED=true | ||
| LOG_LEVEL=DEBUG | ||
| LOG_CONSOLE=true | ||
| LOG_SQL=true | ||
| LOG_FILE=false | ||
| LOG_FILE_OUTPUT=logs/output.log | ||
|
|
||
| BLOB_STORAGE=s3 | ||
| BLOB_STORAGE_S3_ENDPOINT_URL=http://localhost:9000 | ||
| BLOB_STORAGE_S3_REGION=us-east-1 | ||
| BLOB_STORAGE_S3_ACCESS_KEY_ID=s3user | ||
| BLOB_STORAGE_S3_SECRET_ACCESS_KEY=s3user-s3cr3t | ||
| BLOB_STORAGE_S3_BUCKET=test-bucket | ||
| # MAINTENANCE=true | ||
| # MAINTENANCE_MESSAGE=Sorry, we're down for scheduled maintenance right now. | ||
| # MAINTENANCE_UNTIL=about 5 AM PDT | ||
|
|
||
| BLOB_STORAGE_FS_PATH=./testdata/tmp/fs_test | ||
| OAUTH_FACEBOOK_APPID= | ||
| OAUTH_FACEBOOK_SECRET= | ||
|
|
||
| OAUTH_FACEBOOK_APPID=FB_CL_ID | ||
| OAUTH_FACEBOOK_SECRET=FB_CL_SECRET | ||
| OAUTH_GOOGLE_CLIENTID= | ||
| OAUTH_GOOGLE_SECRET= | ||
|
|
||
| OAUTH_GOOGLE_CLIENTID=GO_CL_ID | ||
| OAUTH_GOOGLE_SECRET=GO_CL_SECRET | ||
| OAUTH_GITHUB_CLIENTID= | ||
| OAUTH_GITHUB_SECRET= | ||
|
|
||
| OAUTH_GITHUB_CLIENTID=GH_CL_ID | ||
| OAUTH_GITHUB_SECRET=GH_CL_SECRET | ||
| EMAIL_NOREPLY=noreply@yourdomain.com | ||
|
|
||
| EMAIL_NOREPLY=noreply@random.org | ||
| #EMAIL_MAILGUN_API= | ||
| #EMAIL_MAILGUN_DOMAIN= | ||
| #EMAIL_MAILGUN_REGION=US | ||
|
|
||
| EMAIL_SMTP_HOST=localhost | ||
| EMAIL_SMTP_PORT=1234 | ||
| EMAIL_SMTP_USERNAME=us3r | ||
| EMAIL_SMTP_PASSWORD=p4ss | ||
|
|
||
| EMAIL_MAILGUN_API=mys3cr3tk3y | ||
| EMAIL_MAILGUN_DOMAIN=mydomain.com | ||
|
|
||
| USER_LIST_ENABLED=true | ||
| USER_LIST_APIKEY=abcdefg | ||
| EMAIL_SMTP_PORT=1025 | ||
| EMAIL_SMTP_USERNAME= | ||
| EMAIL_SMTP_PASSWORD= |
| 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") | ||
| } | ||
| } | ||
|
Comment on lines
+29
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
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. |
||
|
|
||
| return v | ||
| } | ||
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.
Why so many changes to this file?
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 changes were unintended - I accidentally replaced the test environment configuration while setting up my local test environment. This has been reverted in commit 6e0210b.