liftoff / GateOne

Gate One is an HTML5-powered terminal emulator and SSH client
http://liftoffsoftware.com/Products/GateOne
Other
6.28k stars 925 forks source link

Unknown WebSocket action: authenticate #715

Open jxs1211 opened 6 years ago

jxs1211 commented 6 years ago

I am running Gateone in an embedded environment and I get an error when trying to access the page. The error that the Gateone server is kicking out is: [E 180828 06:23:43 gateone:1112] Unknown WebSocket action: authenticate [I 180828 06:24:18 gateone:1147] WebSocket closed (ANONYMOUS). [I 180828 06:24:22 web:1462] 200 GET /combined_js (58.84.52.130) 36.01ms [I 180828 06:24:23 web:1462] 200 GET /auth?check=True (58.84.52.130) 1.04ms [I 180828 06:24:23 gateone:1063] WebSocket opened (ANONYMOUS). [E 180828 06:24:23 gateone:1112] Unknown WebSocket action: authenticate

gateone server api_key config is below: auth = "api" ........ api_keys = "YmQwODI3ZTkwMTFiNDc0YWFhOWJjZGUwMDEyODY5MjdiY:NTMwYmI5NWEzZTM3NDMwZTk1Zjc1ZjJjYzlkMTk2OGIxM"

and python code is like this: def authodj(secret, *parts): """ 对secret值安装gateone的要求加密 """ hash = hmac.new(secret, digestmod=hashlib.sha1) for parts in parts: hash.update(str(parts)) return hash.hexdigest()

def get_valid(request): user = "root" gateone_server = "https://x.x.x.x:443"
api_key = "YmQwODI3ZTkwMTFiNDc0YWFhOWJjZGUwMDEyODY5MjdiY" secret = "NTMwYmI5NWEzZTM3NDMwZTk1Zjc1ZjJjYzlkMTk2OGIxM".encode() print(type(secret)) authodj_dict = { "api_key": api_key, "upn": "gateone", "timestamp": str(int(time.time() * 1000)), "signature_method": "HMAC-SHA1", "api_verion": "1.0" } myhash = hmac.new(secret, digestmod=hashlib.sha1) update_data = authodj_dict['api_key'] + authodj_dict['upn'] + authodj_dict['timestamp'] print(type(update_data)) myhash.update(update_data.encode())

myhash.update(update_data)

authodj_dict['signature'] = myhash.hexdigest()
auth_info_and_server = {"url": gateone_server, "auth": authodj_dict}
valid_json_auth_info = json.dumps(auth_info_and_server)
return HttpResponse(valid_json_auth_info)

the front is : $(document).ready( function () { var ip = "login ip";//要登陆的server var port = "22"; var user = "root"; var ssh_url = "ssh://" + user + "@" + ip + ":" + port; //登陆前获取验证的api_key和密码 var request = $.ajax( { url: "/server/get_valid",//请求后台函数,负责校验算法 type: "GET", dataType: "json" } ); //提交给gateone验证 request.done(function (auth_info) {

                console.log("-----------------auth_info.auth---------------------")
                console.log(auth_info.auth);
                console.log("-----------------auth_info.url---------------------")
                console.log(auth_info.url);
                GateOne.init({
                    auth: auth_info.auth, //提交认证信息
                    url: auth_info.url,//认证的地址
                    theme: "solarized",//gateone界面主题样式类型
                    goDiv: "#gateone",//操作元素
                    disableTermTransitions: "true",//显示命令行
                    autoConnectURL: ssh_url//默认登陆的服务器
                });
            });
            //gateone 官方对gateOne界面进行调试的选项
            GateOne.Base.superSandbox(
                "GateOne.SomePlugin",
                ["GateOne", "GateOne.Net", "GateOne.Terminal.Input", "GateOne.Terminal"],
                function (window, undefined) {
                    var location = ip;
                    GateOne.prefs.autoConnectURL = ssh_url;
                    GateOne.prefs.fontSize = "100%";
                    GateOne.prefs.scrollback = 10000;  // scrollback buffer up to 10,000 lines
                    GateOne.Terminal.loadFont("Source Code Pro", "300%");
                    GateOne.Net.setLocation(location);
            });

i checked the gateone server api_key and python code api_key is the same,plz give me a help for the error?