Adds external auth (#6380)

This commit is contained in:
Karolis
2019-05-10 00:05:58 +02:00
committed by Werner
parent 78dee7b9e5
commit 96c2e1c163
12 changed files with 192 additions and 42 deletions
@@ -12,7 +12,7 @@
var/versionstring = null
//The Version Number follows SemVer http://semver.org/
version["major"] = 2 //Major Version Number --> Increment when implementing breaking changes
version["minor"] = 6 //Minor Version Number --> Increment when adding features
version["minor"] = 7 //Minor Version Number --> Increment when adding features
version["patch"] = 0 //Patchlevel --> Increment when fixing bugs
versionstring = "[version["major"]].[version["minor"]].[version["patch"]]"
+55
View File
@@ -170,3 +170,58 @@
response = "Poll data fetched"
data = poll_data
return TRUE
// Authenticates client from external system
/datum/topic_command/auth_client
name = "auth_client"
description = "Authenticates client from external system."
params = list(
"key" = list("name"="key","desc"="Verified key to be set for client.","type"="str","req"=1),
"clienttoken" = list("name"="clienttoken","desc"="Token for identifying the unique client.","type"="str","req"=1),
)
/datum/topic_command/auth_client/run_command(queryparams)
if(!(queryparams["clienttoken"] in unauthed))
statuscode = 404
response = "Client with such token is not found."
return TRUE
var/mob/abstract/unauthed/una = unauthed[queryparams["clienttoken"]]
if(!istype(una) || !una.client)
statuscode = 500
response = "Somethnig went horribly wrong."
return TRUE
if(!config.external_auth)
statuscode = 500
response = "External auth is disalowed."
del(una.client)
del(una)
return TRUE
var/client/cl = directory[ckey(queryparams["key"])]
if(cl)
to_chat(cl, "Another connection has been made using your login key. This session has been terminated.")
del(cl)
statuscode = 200
response = "Client has been authenticated sucessfully."
una.ClientLogin(queryparams["key"])
// Updates external auth state
/datum/topic_command/set_extenal_auth
name = "set_extenal_auth"
description = "Enables or disables external authentication."
params = list(
"state" = list("name"="state","desc"="State to witch option should be updated. If not provided option is toggled.","type"="int","req"=0)
)
/datum/topic_command/set_extenal_auth/run_command(queryparams)
if(queryparams["state"] == null)
config.external_auth = !config.external_auth
else
config.external_auth = queryparams["state"]
statuscode = 200
response = "External authentication state has been updated sucessfully."
data = config.external_auth