Skip to content

Commit

Permalink
Fix CSP failures for Microsoft social sign-in
Browse files Browse the repository at this point in the history
Add login.microsoftonline.com to CSP allow list for `/account/new`, `/account/edit` and `/users/new`

To reproduce:
`/account/edit`
- Login as existing user
- go to "My Settings"
- change "External Authentication" to Microsoft
- click "Save Changes"
- Page fails to load due to CSP violation

`/account/update` ?

`/users/new`
- Login to https://login.live.com with your existing MS account
- navigate to https://www.openstreetmap.com/login
- click on Microsoft Icon to use social account
- on `/user/new` page click "Sign up"
- Page fails to load due to CSP violation
  • Loading branch information
milan-cvetkovic committed May 10, 2024
1 parent ef00f9a commit ea268e9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def edit
@tokens = current_user.oauth_tokens.authorized

append_content_security_policy_directives(
:form_action => %w[accounts.google.com *.facebook.com login.live.com github.com meta.wikimedia.org]
:form_action => %w[accounts.google.com *.facebook.com login.live.com login.microsoftonline.com github.com meta.wikimedia.org]
)

if errors = session.delete(:user_errors)
Expand All @@ -32,7 +32,7 @@ def update
@tokens = current_user.oauth_tokens.authorized

append_content_security_policy_directives(
:form_action => %w[accounts.google.com *.facebook.com login.live.com github.com meta.wikimedia.org]
:form_action => %w[accounts.google.com *.facebook.com login.live.com login.microsoftonline.com github.com meta.wikimedia.org]
)

user_params = params.require(:user).permit(:display_name, :new_email, :pass_crypt, :pass_crypt_confirmation, :auth_provider)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def new
parse_oauth_referer @referer

append_content_security_policy_directives(
:form_action => %w[accounts.google.com *.facebook.com login.live.com github.com meta.wikimedia.org]
:form_action => %w[accounts.google.com *.facebook.com login.live.com login.microsoftonline.com github.com meta.wikimedia.org]
)

if current_user
Expand Down

0 comments on commit ea268e9

Please sign in to comment.