mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
fix: origin validation for web extensions
This commit is contained in:
parent
1cf9963bb6
commit
0fb55f6312
2 changed files with 17 additions and 1 deletions
|
|
@ -24,6 +24,10 @@ class Platform
|
|||
|
||||
public const SCHEME_HTTP = 'http';
|
||||
public const SCHEME_HTTPS = 'https';
|
||||
public const SCHEME_CHROME_EXTENSION = 'chrome-extension';
|
||||
public const SCHEME_FIREFOX_EXTENSION = 'moz-extension';
|
||||
public const SCHEME_SAFARI_EXTENSION = 'extension';
|
||||
public const SCHEME_EDGE_EXTENSION = 'ms-browser-extension';
|
||||
public const SCHEME_IOS = 'appwrite-ios';
|
||||
public const SCHEME_MACOS = 'appwrite-macos';
|
||||
public const SCHEME_WATCHOS = 'appwrite-watchos';
|
||||
|
|
@ -45,6 +49,10 @@ class Platform
|
|||
self::SCHEME_ANDROID => 'Android',
|
||||
self::SCHEME_WINDOWS => 'Windows',
|
||||
self::SCHEME_LINUX => 'Linux',
|
||||
self::SCHEME_CHROME_EXTENSION => 'Chrome Extension',
|
||||
self::SCHEME_FIREFOX_EXTENSION => 'Firefox Extension',
|
||||
self::SCHEME_SAFARI_EXTENSION => 'Safari Extension',
|
||||
self::SCHEME_EDGE_EXTENSION => 'Edge Extension',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -42,7 +42,15 @@ class Origin extends Validator
|
|||
$this->scheme = $this->parseScheme($origin);
|
||||
$this->host = strtolower(parse_url($origin, PHP_URL_HOST) ?? '');
|
||||
|
||||
if (in_array($this->scheme, [Platform::SCHEME_HTTP, Platform::SCHEME_HTTPS], true)) {
|
||||
$webPlatforms = [
|
||||
Platform::SCHEME_HTTP,
|
||||
Platform::SCHEME_HTTPS,
|
||||
Platform::SCHEME_CHROME_EXTENSION,
|
||||
Platform::SCHEME_FIREFOX_EXTENSION,
|
||||
Platform::SCHEME_SAFARI_EXTENSION,
|
||||
Platform::SCHEME_EDGE_EXTENSION,
|
||||
];
|
||||
if (in_array($this->scheme, $webPlatforms, true)) {
|
||||
$validator = new Hostname($this->hostnames);
|
||||
return $validator->isValid($this->host);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue