Skip to content

buildstar-online/unity-self-auth

Repository files navigation

Unity3D Ephemeral Auth

An automated license-management tool for Unity3D built with Python and Selenium.


Watch a demo HERE


Features

  • Create a unity ALF and convert it to a ULF file automatically.
  • Run headless or with a GUI.
  • Built with Docker + Python so it can run in any CI system.
  • Compatible with official GameCI Editor images on Dockerhub

Disclaimers

Warning

Unity isnt a fan of letting you do this with a personal license and has already taken steps to break this style of workflow. I will continue to patch and update as I am able to maintain functionality.

Note

Only personal licences are supported for now becaue I don't have a pro license.

Note

ULF file creation will fail if login is blocked by a 2factor challange. Running from a machine in a region other than the one you have chosen for your unity account will trigger such an event.

Example: running this on my Hetzner machine in Germany fails because Unity security blocks the login, but runs successfully from a local machine. Github hosted runners are all geolocated in the USA, which will trigger the same issue for non-US residents.

Pipelines Usage

  1. Choose an editor image from GameCi's Dockerhub, or bring your own.

    Screenshot 2023-04-23 at 15 33 11
  2. Copy and add the example workflow to your own repo.

  3. Add the following secrets to the repo:

  • UNITY_USERNAME: The email address or username for your Unity account
  • UNITY_PASSWORD: Password for your Unity account.
  • PAT: A personal access token that will be used to store the license as a repo secret.
  1. Run the workflow with your desired Editor Image and Editor Version (leave the selenium image as is).
Screenshot 2023-11-01 at 12 35 02

Command Line Use

# Create a temporary directoy to work in
mkdir -p /tmp/scratch
cd /tmp/scratch

# Export important variables
EDITOR_VERSION="2022.1.23f1"
PLATFORM="webgl-1"
EDITOR_IMAGE="unityci/editor:ubuntu-${EDITOR_VERSION}-${PLATFORM}"
SLENIUM_IMAGE="deserializeme/unity-self-auth:v0.0.1"
USERNAME="YOUR_EMAIL_HERE"
PASSWORD="YOUR_PASSWORD_HERE"

# create a placeholder for the .alf file
touch Unity_v${EDITOR_VERSION}.alf

# Populate the ALF file using the Editor 
docker run --rm -it -v /tmp/scratch/Unity_v${EDITOR_VERSION}.alf:/Unity_v${EDITOR_VERSION}.alf \
    --user root \
    $EDITOR_IMAGE \
    unity-editor -quit \
    -batchmode \
    -nographics \
    -logFile /dev/stdout \
    -createManualActivationFile \
    -username "$USERNAME" \
    -password "$PASSWORD"

## Generate the ULF file via Selenium + Firefox
docker run --rm -it --user 1000:1000 \
    --mount type=bind,source=/tmp/scratch/,target=/home/player1/Downloads \
    -e USERNAME="$USERNAME" \
    -e PASSWORD="$PASSWORD" \
    -e HEADLESS="True" \
    $SLENIUM_IMAGE \
    ./license.py ../Downloads/Unity_v${EDITOR_VERSION}.alf

You can also run graphical session over VNC if desired:

docker run --rm -it --mount type=bind,source=/tmp/scratch/,target=/home/player1/Downloads \
    --user 1000:1000 \
    -p 5900:5900 \
    -e USERNAME="$USERNAME" \
    -e PASSWORD="$PASSWORD" \
    -e HEADLESS="False" \
    $SLENIUM_IMAGE \
    x11vnc --create

# connect to NoVNC remote desktop at <runner-ip>:8080. The default password is `ChangeMe!`

Activate the License:

docker run --rm -it --mount type=bind,source=/tmp/scratch,target=/home/player1/Downloads \
    --user root \
    $EDITOR_IMAGE \
    unity-editor -quit \
    -batchmode \
    -nographics \
    -logFile /dev/stdout \
    -manualLicenseFile /home/player1/Downloads/<ULF FILE NAME>.ulf

TODO

  • Rotating the License automatically via Github Actions is still in testing due to challenges properly obscuring sensitive data in the worflow logs.
  • Selenium script uses explicit sleep/wait calls between page loads which need to be replaces with some smarter "while/until" logic.

About

automation tool for authorizing unity personal liscenses

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published