Git Product home page Git Product logo

omiya-games-web-security's Introduction

Omiya Games - Web Security

openupm Documentation ko-fi

Web Security is a Github package Omiya Games uses to peform various security features for WebGL builds. This includes:

Web Location Checker

A script that verifies the build is running on the correct host. Attach to a GameObject like any other MonoBehavior, then call the coroutine, CheckDomainList(), from another script. For example, one can create a script with the method below, then attach it to the same GameObject the WebLocationChecker is on:

IEnumerator Start()
{
    // Verify the domain
    WebLocationChecker checker = GetComponent<WebLocationChecker>();
    yield return StartCoroutine(checker.CheckDomainList());

    // Check if the domain was verified
    if(checker.CurrentState == WebLocationChecker.State.DomainMatched)
    {
        // Change scene to the main menu
        SceneManager.LoadScene("Main menu");
    }
}

The script contains the following inspector fields:

Inspector

Field Required? Description
Remote Domain List Url No The path to download a DomainList, relative to the root of the WebGL build (typically where index.html is in). The strings in the DomainList will be used to match the domain the build is running on, in addition to strings listed in Domain Must Contain. Leave empty if no file should be downloaded.
Domain Decrypter No The StringCryptographer to use to decrypt the content of the downloaded DomainList. Entirely optional, especially if the downloaded file is not expected to be encrypted.
GameObjects to Deactivate No A list of GameObjects to deactivate while the script verifies the domain the build is running on.
Domain Must Contain Yes A list of strings to verify whether the domain the game is running on matches. This script supports ? and * wildcards (former any single character, while the latter matches a series of character).
Force Redirect No If checked, and the domain did not match, prompts the script to redirect to a different website. If this build is embedded in an iframe with redirect permission restrictions (which most browsers enable by default), the redirect may fail with an AccessDenied error.
Redirect URL If Force Redirect is checked The URL to redirect to if the doamin did not match. This URL should include https://

Install

There are two common methods for installing this package.

Unity's own Package Manager supports importing packages through a URL to a Git repo:

  1. First, on this repository page, click the "Clone or download" button, and copy over this repository's HTTPS URL.
  2. Then click on the + button on the upper-left-hand corner of the Package Manager, select "Add package from git URL..." on the context menu, then paste this repo's URL!

While easy and straightforward, this method has a few major downside: it does not support dependency resolution and package upgrading when a new version is released. To add support for that, the following method is recommended:

Through OpenUPM

Installing via OpenUPM's command line tool is recommended because it supports dependency resolution, upgrading, and downgrading this package.

If you haven't already installed OpenUPM, you can do so through Node.js's npm (obviously have Node.js installed in your system first):

npm install -g openupm-cli

Then, to install this package, just run the following command at the root of your Unity project:

openupm add com.omiyagames.web.security

Resources

LICENSE

Overall package is licensed under MIT, unless otherwise noted in the 3rd party licenses file and/or source code.

Copyright (c) 2019-2021 Omiya Games

omiya-games-web-security's People

Contributors

japtar10101 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

omiya-games-web-security's Issues

[DOC] Document how to use the new WebDomainVerifier

Is your request related to a feature? Please describe.

README.md is not updated with screenshots and descriptions of how to use the WebDomainVerifier, which now replaces WebLocationChecker.

Describe what changes in documentation you'd like.

Update README.md with instructions on how to use the WebDomainVerifier.

Tasklist

  • Update Screenshots
  • Indicate what all fields do
  • Provide an example script of how to use WebDomainVerifier.

[FEATURE] Migrate WebLocationChecker to a project settings window

Is your feature request related to a problem? Please describe.

Web Location Checker.

Describe the solution you'd like

It seems Unity is opening up the API to add windows under Project Settings and Preferences. Since the web location checker is shared across the entire project, it'd be better to move the feature to a Project Settings window. If possible, consider moving the entire project to its own Unity package.

Tasklist

  • Look into whether Project Settings data can be accessed on runtime.
    • Yes you can! It also appears one can create asset files in the ProjectSettings folder, like any Unity project settings file.
  • If not, look into the effort of creating a ScriptableObject.
  • Make nearly everything about the WebLocationChecker statically accessible. Store only one instance of its statuses.
  • Look into moving the project into its own Unity package.

Describe alternatives you've considered

The current method, which everything is stored in a Singleton prefab. Not useful, as the information is likely not needed to be set on runtime.

Additional context

Part of an effort to decouple a lot of the Singleton scripts. See Issue #19 .

[FEATURE] Port Web Host Checker as its own package

Is your feature request related to a problem? Please describe.

Task copied over from Template Unity Project.

Describe the solution you'd like

Split the parts that verifies the WebGL build's web host into a new package.

Tasklist

  • Look into what files can be moved into its own Unity package.
  • Verify WebHostChecker does not rely on Singleton.
    • If it does, make it not rely on it.
  • Move the files.
  • Shift debugging functions to their own script so Unity doesn't compile them when making a build that doesn't use said script.
  • If the script loads-in the DomainList, look into unloading later.
  • Create a sample project with the debugging enabled.
  • Create a sample project with actual web-host checking setup properly.

Additional context

Part of the effort to create the Web Host Checker package effort.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.