共享token

main
吴顺明 9 months ago
parent 4a12eba6df
commit 4f91cdd368

@ -101,7 +101,6 @@ namespace UMC.ITME
try try
{ {
Subscribe(this._data, e.Offset + 1, e.BytesTransferred - 1); Subscribe(this._data, e.Offset + 1, e.BytesTransferred - 1);
// _socket = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -119,7 +118,6 @@ namespace UMC.ITME
} }
var req = this.Request; var req = this.Request;
// req.Receive(this._data, 0, size);
req.Receive(this._data, e.Offset, e.BytesTransferred); req.Receive(this._data, e.Offset, e.BytesTransferred);
@ -131,7 +129,6 @@ namespace UMC.ITME
else if (this.isDispose == false) else if (this.isDispose == false)
{ {
return true; return true;
// ProcessReceive(e);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -158,12 +155,13 @@ namespace UMC.ITME
var ps = System.Text.Encoding.UTF8.GetString(header, offset, size).Split("\r\n", StringSplitOptions.RemoveEmptyEntries); var ps = System.Text.Encoding.UTF8.GetString(header, offset, size).Split("\r\n", StringSplitOptions.RemoveEmptyEntries);
foreach (var s in ps) foreach (var s in ps)
{ {
var vi = s.IndexOf(':'); var vi = s.IndexOf(':');
var key = s.Substring(0, vi); if (vi > 0 && vi + 2 < s.Length)
var value = s.Substring(vi + 2); {
headers.Add(key, value); var key = s.Substring(0, vi);
var value = s.Substring(vi + 2);
headers.Add(key, value);
}
} }
int length = 0; int length = 0;

@ -29,12 +29,8 @@ namespace UMC.ITME
} }
return _Instance; return _Instance;
} }
static DataFactory _Instance;// = new DataFactory(); static DataFactory _Instance;
// public static void Instance(DataFactory dataFactory)
// {
// _Instance = dataFactory;
// NetSubscribe.Subscribe("SiteConfig", _Instance);
// }
public virtual Site[] Site() public virtual Site[] Site()
@ -43,12 +39,6 @@ namespace UMC.ITME
return HotCache.Cache<Site>().Find(new Entities.Site(), 0, out index); return HotCache.Cache<Site>().Find(new Entities.Site(), 0, out index);
} }
// public virtual Device[] Devices()
// {
// int index;
// return HotCache.Cache<Device>().Find(new Entities.Device(), 0, out index);
// }
public virtual Site Site(String root) public virtual Site Site(String root)
@ -134,10 +124,6 @@ namespace UMC.ITME
} }
} }
public virtual String Evaluate(String js, params string[] args)
{
return "";
}
public virtual Stream Decompress(Stream response, string encoding) public virtual Stream Decompress(Stream response, string encoding)
{ {
switch (encoding) switch (encoding)

@ -911,12 +911,12 @@ namespace UMC.ITME
if (String.IsNullOrEmpty(sStrDomain) == false) if (String.IsNullOrEmpty(sStrDomain) == false)
{ {
getUrl = new Uri(sStrDomain);// new Uri(new, PathAndQuery); getUrl = new Uri(sStrDomain);
} }
else else
{ {
getUrl = Domain;// new Uri(Domain, PathAndQuery); getUrl = Domain;
} }
var Method = login["Method"] as string ?? "GET"; var Method = login["Method"] as string ?? "GET";
@ -1312,14 +1312,6 @@ namespace UMC.ITME
var checkConfig = GetConf(String.Format("SITE_MIME_{0}_CHECK", proxy.Site.Root).ToUpper()); var checkConfig = GetConf(String.Format("SITE_MIME_{0}_CHECK", proxy.Site.Root).ToUpper());
if (checkConfig.ContainsKey("Finish")) if (checkConfig.ContainsKey("Finish"))
{ {
// if (String.IsNullOrEmpty(proxy.Site.Home) == false && proxy.Site.Home.StartsWith("http") == false)
// {
// var r = proxy.Reqesut(this.Context.Transfer(new Uri(proxy.Domain, proxy.Site.Home))).Get();
// proxy.SetCookie(r);
// }
var config = new Hashtable(); var config = new Hashtable();
if (proxy.IsLog == true) if (proxy.IsLog == true)
@ -2788,7 +2780,7 @@ namespace UMC.ITME
} }
bool SaveCookie() internal bool SaveCookie()
{ {
if (this.IsChangeUser == true) if (this.IsChangeUser == true)
@ -2828,6 +2820,7 @@ namespace UMC.ITME
} }
siteCookie.Config = this.SiteCookie.Config; siteCookie.Config = this.SiteCookie.Config;
siteCookie.Cookies = this.SiteCookie.Cookies;
siteCookie.LoginTime = UMC.Data.Utility.TimeSpan(); siteCookie.LoginTime = UMC.Data.Utility.TimeSpan();
this.IsChangeUser = null; this.IsChangeUser = null;
DataFactory.Instance().Put(siteCookie); DataFactory.Instance().Put(siteCookie);
@ -3025,6 +3018,21 @@ namespace UMC.ITME
this.Context.AddHeader(key, this.Context.Headers.Get("Origin") ?? m_HttpHeaders.Get(i)); this.Context.AddHeader(key, this.Context.Headers.Get("Origin") ?? m_HttpHeaders.Get(i));
// } // }
break; break;
case "itme-access-token":
if (this.Site.Site.UserModel == Entities.UserModel.Bridge)
{
var access = m_HttpHeaders.Get(i);
if (String.Equals(this.SiteCookie.Cookies, access) == false)
{
this.SiteCookie.Cookies = access;
this.IsChangeUser = true;
}
}
else
{
goto default;
}
break;
case "strict-transport-security": case "strict-transport-security":
case "content-type": case "content-type":
case "server": case "server":
@ -3267,6 +3275,16 @@ namespace UMC.ITME
user = this.Account; user = this.Account;
} }
break; break;
case Entities.UserModel.Bridge:
if (this.Site.Site.IsAuth == true)
{
user = this.Account;
}
if (String.IsNullOrEmpty(this.SiteCookie.Cookies) == false)
{
heaers.Add("itme-access-token", this.SiteCookie.Cookies);
}
break;
} }
heaers.Add("umc-request-user-name", Uri.EscapeDataString(user.Name)); heaers.Add("umc-request-user-name", Uri.EscapeDataString(user.Name));
heaers.Add("umc-request-user-id", UMC.Data.Utility.Guid(user.Id.Value)); heaers.Add("umc-request-user-id", UMC.Data.Utility.Guid(user.Id.Value));

@ -923,7 +923,7 @@ namespace UMC.ITME.Activities
style.BgColor(0xfafcff).Height(180).AlignCenter(); style.BgColor(0xfafcff).Height(180).AlignCenter();
from.AddHeader(new UIHeader().Desc(new UMC.Web.WebMeta().Put("title", "配置市场应用需要证书").Put("icon", "\uea05"), "{icon}\n{title}", style)); from.AddHeader(new UIHeader().Desc(new UMC.Web.WebMeta().Put("title", "配置市场应用需要证书").Put("icon", "\uea05"), "{icon}\n{title}", style));
from.Add(UICell.QRCode($"https://api.apiumc.com/UMC/Platform/EditCert/{appId}/{Seller}")); from.Add(new UIQRCode($"https://api.apiumc.com/UMC/Platform/EditCert/{appId}/{Seller}"));
from.AddFooter("请应用开发者用ITME App扫一扫生成证书再点击下一步", "Settings", "YES"); from.AddFooter("请应用开发者用ITME App扫一扫生成证书再点击下一步", "Settings", "YES");
from.Submit("下一步", $"{request.Model}.{request.Command}"); from.Submit("下一步", $"{request.Model}.{request.Command}");

@ -84,7 +84,7 @@ namespace UMC.ITME.Activities
} }
from.Title = "开发者发布"; from.Title = "开发者发布";
from.Add(UICell.QRCode($"https://api.apiumc.com/UMC/Platform/EditCert/{appId}")); from.Add(new UIQRCode($"https://api.apiumc.com/UMC/Platform/EditCert/{appId}"));
from.AddFooter("请开发者用ITME App扫一扫生成开发者证书再点击下一步", "Settings", "YES"); from.AddFooter("请开发者用ITME App扫一扫生成开发者证书再点击下一步", "Settings", "YES");
from.Submit("下一步", $"{request.Model}.{request.Command}"); from.Submit("下一步", $"{request.Model}.{request.Command}");

@ -233,13 +233,23 @@ namespace UMC.ITME
webReq.ContentType = "application/x-www-form-urlencoded"; webReq.ContentType = "application/x-www-form-urlencoded";
webReq.Post(sb.ToString(), res => webReq.Post(sb.ToString(), res =>
{ {
var token = res.Headers.Get("itme-access-token");
if (String.IsNullOrEmpty(token) == false)
{
if (String.Equals(httpProxy.SiteCookie.Cookies, token) == false)
{
httpProxy.SiteCookie.Cookies = token;
httpProxy.IsChangeUser = true;
httpProxy.SaveCookie();
}
}
int StatusCode = (int)res.StatusCode; int StatusCode = (int)res.StatusCode;
HttpProxy.LogWrite(httpProxy.Context, httpProxy.Site, 200, webReq.RawUrl, httpProxy.SiteCookie.Account, null, String.Empty); HttpProxy.LogWrite(httpProxy.Context, httpProxy.Site, StatusCode, webReq.RawUrl, httpProxy.SiteCookie.Account, null, String.Empty);
if (StatusCode > 300 && StatusCode < 400) if (StatusCode > 300 && StatusCode < 400)
{ {
httpProxy.ProcessEnd();
var url = res.Headers.Get("Location"); var url = res.Headers.Get("Location");
response.Headers.Put("Data", new Uri(content.Url, url)); response.Headers.Put("Data", new Uri(content.Url, url));
response.ClientEvent |= (WebEvent)131072; response.ClientEvent |= (WebEvent)131072;

Loading…
Cancel
Save