Skip to content

Commit

Permalink
Assert protocol in oauth redirect_uri (#6618)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson authored Nov 8, 2023
1 parent 82b0ce9 commit 6c45cfb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/docs/developers/log-in-with-audius.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ You must open this page with the required URL parameters, described below.

- scope `"read" | "write"` - the scope of the authentication request. Use `"write"` if your app will request read/write access to the user's account; otherwise, use `"read"` if your app only needs read access.
- api_key `string` - your app's Audius API Key. If you don't have one, you can create one on the Audius [Settings page](https://audius.co/settings).
- redirect_uri `string` - the location that the Audius login page should redirect to once the user successfully authenticates. Custom URL schemes are allowed and supported. You can use the special value `postmessage` here if you would like the login page to send the response back to its opener using `window.postMessage` instead of using a redirect. Otherwise, the following validation rules apply:
- redirect_uri `string` - the location that the Audius login page should redirect to once the user successfully authenticates. A URL protocol of http or https is required. You can use the special value `postmessage` here if you would like the login page to send the response back to its opener using `window.postMessage` instead of using a redirect. Otherwise, the following validation rules apply:

- Hosts cannot be raw IP addresses UNLESS they are localhost IP addresses
- Cannot contain the fragment component (`#`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ You must open this page with the required URL parameters, described below.

- scope `"read" | "write"` - the scope of the authentication request. Use `"write"` if your app will request read/write access to the user's account; otherwise, use `"read"` if your app only needs read access.
- api_key `string` - your app's Audius API Key. If you don't have one, you can create one on the Audius [Settings page](https://audius.co/settings).
- redirect_uri `string` - the location that the Audius login page should redirect to once the user successfully authenticates. Custom URL schemes are allowed and supported. You can use the special value `postmessage` here if you would like the login page to send the response back to its opener using `window.postMessage` instead of using a redirect. Otherwise, the following validation rules apply:
- redirect_uri `string` - the location that the Audius login page should redirect to once the user successfully authenticates. A URL protocol of http or https is required. You can use the special value `postmessage` here if you would like the login page to send the response back to its opener using `window.postMessage` instead of using a redirect. Otherwise, the following validation rules apply:

- Hosts cannot be raw IP addresses UNLESS they are localhost IP addresses
- Cannot contain the fragment component (`#`)
Expand Down
9 changes: 8 additions & 1 deletion packages/web/src/pages/oauth-login-page/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export const getIsRedirectValid = ({
if (parsedRedirectUri === 'postmessage') {
return true
}
const { hash, username, password, pathname, hostname } = parsedRedirectUri
const { hash, username, password, pathname, hostname, protocol } = parsedRedirectUri
// Ensure that the redirect_uri protocol is http or https
// IMPORTANT: If this validation is not done, users can
// use the redirect_uri to execute arbitrary code on the host
// domain (e.g. audius.co).
if (protocol !== 'http' && protocol !== 'https') {
return false
}
if (hash || username || password) {
return false
}
Expand Down

0 comments on commit 6c45cfb

Please sign in to comment.