Skip to content

Commit

Permalink
fix(auth): add requirement renderfusion perms when package manager in…
Browse files Browse the repository at this point in the history
…stalled (#111)

* fix(auth): allow scrolling of token permissions ui

* draft package detect for render fusion

* fix(mqtt): add requirement renderfusion perms with context request
  • Loading branch information
mwfarb authored Nov 15, 2024
1 parent cd6927b commit 688c901
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Runtime/ArenaClientEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override void OnInspectorGUI()
{
GUILayout.BeginVertical("Box");
GUILayout.Label("Permissions");
scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Infinity), GUILayout.Height(250));
GUILayout.Label(script.permissions);
GUILayout.EndScrollView();
GUILayout.EndVertical();
Expand Down
21 changes: 21 additions & 0 deletions Runtime/ArenaMqttClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using UnityEngine;
using UnityEngine.Networking;
using uPLibrary.Networking.M2Mqtt;
Expand Down Expand Up @@ -61,6 +63,8 @@ public class ArenaMqttClient : M2MqttUnityClient
const string mqttTokenFile = ".arena_mqtt_auth";
const string userDirArena = ".arena";
const string userSubDirUnity = "unity";
private const string packageNameRenderFusion = "io.conix.arena.renderfusion";

public string appFilesPath { get; private set; }
public string userid { get; private set; }
public string userclient { get; private set; }
Expand All @@ -81,6 +85,7 @@ public enum Auth { Anonymous, Google, Manual };

private List<byte[]> eventMessages = new List<byte[]>();
protected Dictionary<ushort, string> subscriptions = new Dictionary<ushort, string>();
private ListRequest packageListRequest;

// MQTT methods

Expand All @@ -95,6 +100,7 @@ protected override void Awake()
{
verifyCertificate = false;
}
packageListRequest = Client.List(true); // request offline packages installed
StartCoroutine(PublishTickLatency());
}

Expand Down Expand Up @@ -340,6 +346,21 @@ private IEnumerator Signin(string sceneName, string namespaceName, string realm,
{
form.AddField("scene", $"{namespaceName}/{sceneName}");
}
// test for render fusion, request permissions if so
if (packageListRequest.IsCompleted)
{
if (packageListRequest.Status == StatusCode.Success)
foreach (var package in packageListRequest.Result)
if (package.name == packageNameRenderFusion)
form.AddField("renderfusionid", "true");
else if (packageListRequest.Status >= StatusCode.Failure)
Debug.LogWarning(packageListRequest.Error.message);
}
else
{
Debug.LogWarning("Package Manager unable to query for render-fusion package!");
}
// request token endpoint
cd = new CoroutineWithData(this, HttpRequestAuth($"https://{hostAddress}/user/v2/mqtt_auth", csrfToken, form));
yield return cd.coroutine;
if (!isCrdSuccess(cd.result)) yield break;
Expand Down

0 comments on commit 688c901

Please sign in to comment.