LiveNVR traditional IP camera access - live web cross-domain authentication


LiveNVR how to implement cross-domain authentication

LiveNVR provides simple login authentication, the client through a username and password login is successful, the server returns the cookie authentication token, the subsequent interface to access, verify the server reads the token from the cookie. However, when integrated with customer systems often need to complete the authentication process on the client system. then on issues related to cross-domain. so, this set of cross-domain authentication process how to apply to the scene it?

Server process

The server needs to do the following treatment:

  1. The login is successful, the server actively write token in a cookie

    According to the previous interface design, the login is successful, the server returns the HTTP Response Body in the token, the client will be responsible for their own token write cookie. In cross-domain scenario, this will not work, due to the limitations of the browser, the client can not the token wrote nonsubtyped domain cookie. server instead take the initiative to write token cookie do not have this problem. Add the server in the HTTP Response Header Set-Cookiefield, writetoken=xxx

  2. End unified service charge and promised to do cross-domain access settings

    Xu cross-domain configuration server charge and carries cookie, you need to add the following two in the HTTP Response Header:

    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: $http_origin

    Access-Control-Allow-Origin can not be arranged *, but seek current client before HTTT Origin

  3. When log off, the server will take the initiative to clean up the token from the cookie

    Set-Cookie: token=; expires=Thu, 01 Jan 1970 00:00:00 GMT;

The client process

The client does not have to show to save the token cookie. LiveNVR the interactive interface and all you need to add cross-domain configuration, xhrFields: { withCredentials: true }andcrossDomain: true

Such as cross-domain calls sample login interfaces as follows:

$.ajax({
    type: "GET",
    url: "http://other-domain/api/v1/login",
    xhrFields: { 
        withCredentials: true
    },
    crossDomain: true, 
    data: {
        username: 'admin',
        password: '21232f297a57a5a743894a0e4a801fc3'//admin
    }
});

About LiveNVR

LiveNVR network camera through a simple channel configuration, the traditional industry, which monitor network camera HD IP Camera, NVR equipment having access to the RTSP protocol output LiveNVR, LiveNVR these audio and video data can be video sources is a pull converter as RTMP / HLS, full platform terminal H5 live (Web, Android, iOS), and LiveNVR able to live on a live video source data to a third party CDN network, internet-scale distribution;

For more information

Live Streaming Internet Security -QQ exchange group: 615 081 503

GB GB28181 no plug-ins LiveGBS-QQ exchange group: 947 137 753

Mail: [email protected]

WEB:www.liveqing.com

Tel: 189-5515-0114 (the same micro-channel)

Copyright © LiveQing.com 2016-2019

Guess you like

Origin www.cnblogs.com/marvin1311/p/10936994.html
Recommended