[Android] Remote Access: authenticate /logs endpoint

Nicolas Pomepuy git at videolan.org
Wed Jul 22 14:16:26 UTC 2026


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jul 20 12:03:16 2026 +0200| [4ffb22b65b97c809330621234ba2811f627d8f56] | committer: Duncan McNamara

Remote Access: authenticate /logs endpoint

The `/logs` POST endpoint is now protected by the `user_session` authentication block.

> https://code.videolan.org/videolan/vlc-android/commit/4ffb22b65b97c809330621234ba2811f627d8f56
---

 .../vlc/remoteaccessserver/RemoteAccessRouting.kt  | 98 +++++++++++-----------
 1 file changed, 49 insertions(+), 49 deletions(-)

diff --git a/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessRouting.kt b/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessRouting.kt
index 52d33835ae..09b2466b23 100644
--- a/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessRouting.kt
+++ b/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessRouting.kt
@@ -390,65 +390,65 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) {
 
     }
 
-    post ("/logs") {
-        val formParameters = try {
-            call.receiveParameters()
-        } catch (e: Exception) {
-            null
-        }
-        val logs = buildString {
-            formParameters?.forEach { s, strings ->
-                if (s.contains("[time]"))
-                    append(format.get()?.format(strings[0].toLong()))
-                else if (s.contains("[level]")) {
-                    append(" - ")
-                    append(strings[0])
-                } else {
-                    strings.forEach {
+    authenticate("user_session", optional = RemoteAccessServer.byPassAuth) {
+        post("/logs") {
+            val formParameters = try {
+                call.receiveParameters()
+            } catch (e: Exception) {
+                null
+            }
+            val logs = buildString {
+                formParameters?.forEach { s, strings ->
+                    if (s.contains("[time]"))
+                        append(format.get()?.format(strings[0].toLong()))
+                    else if (s.contains("[level]")) {
                         append(" - ")
-                        append(it)
-                        append("*")
+                        append(strings[0])
+                    } else {
+                        strings.forEach {
+                            append(" - ")
+                            append(it)
+                            append("*")
+                        }
                     }
                 }
             }
-        }
 
-        //save
-        val timestamp = android.text.format.DateFormat.format("yyyyMMdd_kkmmss", System.currentTimeMillis())
-        val filename = File("${AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY}/vlc_logcat_remote_access_${timestamp}.log")
-        var saved = true
-        var fos: FileOutputStream? = null
-        var output: OutputStreamWriter? = null
-        var bw: BufferedWriter? = null
+            //save
+            val timestamp = android.text.format.DateFormat.format("yyyyMMdd_kkmmss", System.currentTimeMillis())
+            val filename = File("${AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY}/vlc_logcat_remote_access_${timestamp}.log")
+            var saved = true
+            var fos: FileOutputStream? = null
+            var output: OutputStreamWriter? = null
+            var bw: BufferedWriter? = null
 
-        try {
-            fos = FileOutputStream(filename)
-            output = OutputStreamWriter(fos)
-            bw = BufferedWriter(output)
-            synchronized(this) {
-                bw.write(FeedbackUtil.generateUsefulInfo(appContext))
-                for (line in logs.split(("*"))) {
-                    bw.write(line)
-                    bw.newLine()
+            try {
+                fos = FileOutputStream(filename)
+                output = OutputStreamWriter(fos)
+                bw = BufferedWriter(output)
+                synchronized(this) {
+                    bw.write(FeedbackUtil.generateUsefulInfo(appContext))
+                    for (line in logs.split(("*"))) {
+                        bw.write(line)
+                        bw.newLine()
+                    }
                 }
+            } catch (e: FileNotFoundException) {
+
+                saved = false
+            } catch (ioe: IOException) {
+                saved = false
+            } finally {
+                saved = saved and CloseableUtils.close(bw)
+                saved = saved and CloseableUtils.close(output)
+                saved = saved and CloseableUtils.close(fos)
             }
-        } catch (e: FileNotFoundException) {
 
-            saved = false
-        } catch (ioe: IOException) {
-            saved = false
-        } finally {
-            saved = saved and CloseableUtils.close(bw)
-            saved = saved and CloseableUtils.close(output)
-            saved = saved and CloseableUtils.close(fos)
+            if (!saved)
+                call.respond(HttpStatusCode.InternalServerError)
+            else
+                call.respondText("")
         }
-
-        if (!saved)
-            call.respond(HttpStatusCode.InternalServerError)
-        else
-            call.respondText("")
-    }
-    authenticate("user_session", optional = RemoteAccessServer.byPassAuth) {
         //Provide a Websocket auth ticket as auth is validated
         get("/wsticket") {
             val ticket = RemoteAccessWebSockets.createTicket()



More information about the Android mailing list