Class WebDomainVerifier
Original code by andyman from Github:
https://gist.github.com/andyman/e58dea85cce23cccecff
Extra modifications by jcx from Github:
https://gist.github.com/jcx/93a3fc93531911add8a8
For WebGL builds, this script grabs the domain of the website this game is running on, and verifies it against two lists:
- The list of strings in DefaultDomainList.
-
Optionally, if RemoteDomainListUrl isn't an empty string
(or null), this script will attempt to download from the specified url,
and read it as a
. If successful, the globs listed in the will be used to match the domain as well. Remember that if the is encrypted, the OmiyaGames.Web.Security.WebDomainVerifier.domainDecrypter needs to be set in the Unity inspector to help decrypt the content of the list.
[SerializeField]
private WebDomainVerifier domainVerifier;
IEnumerator Start()
{
yield return StartCoroutine(domainVerifier.VerifyWebDomain());
Debug.Log(domainVerifier.CurrentState);
}
Namespace: OmiyaGames.Web.Security
Assembly: cs.temp.dll.dll
Syntax
public class WebDomainVerifier : ScriptableObject
Remarks
Copyright (c) 2020-2020 Omiya Games Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Revision | Description |
---|---|
Version: 0.2.0-preview.1 Date: 6/29/2020 Author: Taro Omiya | Initial verison. |
Version: 0.2.0-preview.2 Date: 10/1/2020 Author: Taro Omiya | Exposing DomainDecrypter. |
Fields
RemoteDomainListHeader
Header string for the Unity Inspector.
Declaration
public const string RemoteDomainListHeader = "Remote Domain List"
Field Value
Type | Description |
---|---|
String |
SidebarDisplayPath
Path where this asset will be created.
Declaration
public const string SidebarDisplayPath = "Project/Omiya Games/Web Security"
Field Value
Type | Description |
---|---|
String |
Properties
AllUniqueDomains
The
Declaration
public Dictionary<string, Regex> AllUniqueDomains { get; }
Property Value
Type | Description |
---|---|
Dictionary<String, Regex> |
CurrentState
Indicates the state this script is in. WebDomainVerifier.State
Declaration
public WebDomainVerifier.State CurrentState { get; }
Property Value
Type | Description |
---|---|
WebDomainVerifier.State |
DefaultDomainList
The default list of domains to match RetrievedHostName against.
This list excludes the globs stored in a
Declaration
public string[] DefaultDomainList { get; }
Property Value
Type | Description |
---|---|
String[] |
DomainDecrypter
Gets the cryptographer that decrypts the domain list downloaded from RemoteDomainListUrl.
Declaration
public StringCryptographer DomainDecrypter { get; }
Property Value
Type | Description |
---|---|
StringCryptographer |
DownloadDomainsUrl
The URL used to download a
Declaration
public string DownloadDomainsUrl { get; }
Property Value
Type | Description |
---|---|
String |
DownloadedDomainList
The list of globs in a
Declaration
public string[] DownloadedDomainList { get; }
Property Value
Type | Description |
---|---|
String[] |
DownloadErrorMessage
Indicates the error when attempting to download a
Declaration
public string DownloadErrorMessage { get; }
Property Value
Type | Description |
---|---|
String |
IsDomainListSuccessfullyDownloaded
Indicates if a
Declaration
public bool IsDomainListSuccessfullyDownloaded { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsDownloadingARemoteDomainList
True if downloading a domain list from a remote URL.
Declaration
public bool IsDownloadingARemoteDomainList { get; }
Property Value
Type | Description |
---|---|
Boolean |
RemoteDomainListUrl
The original URL to download a
Declaration
public string RemoteDomainListUrl { get; }
Property Value
Type | Description |
---|---|
String |
RetrievedHostName
The domain this WebGL build is running on.
Declaration
public string RetrievedHostName { get; }
Property Value
Type | Description |
---|---|
String |
Methods
ForceRedirect()
Makes the build redirect the browser to OmiyaGames.Web.Security.WebDomainVerifier.redirectURL.
Declaration
public void ForceRedirect()
VerifyWebDomain()
Declaration
public IEnumerator VerifyWebDomain()
Returns
Type | Description |
---|---|
IEnumerator |
Events
OnAfterStateChange
Called right after CurrentState changes to a new value.
Declaration
public event WebDomainVerifier.OnStateChange OnAfterStateChange
Event Type
Type | Description |
---|---|
WebDomainVerifier.OnStateChange |
OnAfterVerifyWebDomain
Called around when the VerifyWebDomain() coroutine finishes.
Declaration
public event WebDomainVerifier.OnVerifyWebDomain OnAfterVerifyWebDomain
Event Type
Type | Description |
---|---|
WebDomainVerifier.OnVerifyWebDomain |
OnBeforeStateChange
Called right before CurrentState changes to a new value.
Declaration
public event WebDomainVerifier.OnStateChange OnBeforeStateChange
Event Type
Type | Description |
---|---|
WebDomainVerifier.OnStateChange |
OnBeforeVerifyWebDomain
Called just as the VerifyWebDomain() coroutine starts processing.
Declaration
public event WebDomainVerifier.OnVerifyWebDomain OnBeforeVerifyWebDomain
Event Type
Type | Description |
---|---|
WebDomainVerifier.OnVerifyWebDomain |