internal static async Task <string> GetIdentityServerSignoutFrameCallbackUrlAsync(this HttpContext context, LogoutMessage logoutMessage = null) { var userSession = context.RequestServices.GetRequiredService <IUserSession>(); var user = await userSession.GetIdentityServerUserAsync(); var currentSubId = user?.GetSubjectId(); EndSession endSessionMsg = null; // if we have a logout message, then that take precedence over the current user if (logoutMessage?.ClientIds?.Any() == true) { var clientIds = logoutMessage?.ClientIds; // check if current user is same, since we migth have new clients (albeit unlikely) if (currentSubId == logoutMessage?.SubjectId) { clientIds = clientIds.Union(await userSession.GetClientListAsync()); clientIds = clientIds.Distinct(); } endSessionMsg = new EndSession { SubjectId = logoutMessage.SubjectId, SessionId = logoutMessage.SessionId, ClientIds = clientIds }; } else if (currentSubId != null) { // see if current user has any clients they need to signout of var clientIds = await userSession.GetClientListAsync(); if (clientIds.Any()) { endSessionMsg = new EndSession { SubjectId = currentSubId, SessionId = await userSession.GetCurrentSessionIdAsync(), ClientIds = clientIds }; } } if (endSessionMsg != null) { var msg = new Message <EndSession>(endSessionMsg); var endSessionMessageStore = context.RequestServices.GetRequiredService <IMessageStore <EndSession> >(); var id = await endSessionMessageStore.WriteAsync(msg); var signoutIframeUrl = context.GetIdentityServerBaseUrl().EnsureTrailingSlash() + Constants.ProtocolRoutePaths.EndSessionCallback; signoutIframeUrl = signoutIframeUrl.AddQueryString(Constants.UIConstants.DefaultRoutePathParams.EndSessionCallback, id); return(signoutIframeUrl); } // no sessions, so nothing to cleanup return(null); }
public void ComparingEntitiesSession() { for (int i = 0; i < 3; i++) { long ts = TimeHelper.UnixTimeNow(); BeginSession bs0 = TestHelper.CreateBeginSession(i, i, ts); BeginSession bs1 = TestHelper.CreateBeginSession(i, i, ts); BeginSession bs2 = TestHelper.CreateBeginSession(i + 1, i, ts); BeginSession bs3 = TestHelper.CreateBeginSession(i, i + 1, ts); Assert.Equal(bs0, bs1); Assert.NotEqual(bs1, bs2); Assert.NotEqual(bs1, bs3); EndSession es0 = TestHelper.CreateEndSession(i, ts); EndSession es1 = TestHelper.CreateEndSession(i, ts); EndSession es2 = TestHelper.CreateEndSession(i + 1, ts); Assert.Equal(es0, es1); Assert.NotEqual(es1, es2); UpdateSession us0 = TestHelper.CreateUpdateSession(i, i, ts); UpdateSession us1 = TestHelper.CreateUpdateSession(i, i, ts); UpdateSession us2 = TestHelper.CreateUpdateSession(i + 1, i, ts); Assert.Equal(us0, us1); Assert.NotEqual(us1, us2); } }
void OnEnable() { //Debug.Log("Firebase script enabled"); MLEyes.Start(); //Get the current session and set CurrentSessionLocal. This is done here in enable to avoid doing it over and over again in update. Less expensive. EndSession EndSessionScript = EntireScene.GetComponent <EndSession>(); CurrentSessionLocal = EndSessionScript.selectedSession; //New. We remove newOrgio from the UFO's position. This is so that it moves accordingly to origo. This is so that all three 'systems' eye/head and now target, all uses origo as a base. newOrgio = TargetPatternSphere.transform.position; //The FixationConfidence could be set somewhere else. Right now it is being set and overwritten three times. user.FixationConfidence = MLEyes.FixationConfidence; }
public void ComparingEntitiesSessionNull() { long ts = TimeHelper.UnixTimeNow(); BeginSession bs0 = TestHelper.CreateBeginSession(0, 0, ts); BeginSession bs1 = TestHelper.CreateBeginSession(0, 0, ts); bs1.Content = bs0.Content; Assert.Equal(bs0, bs1); bs0.Content = null; bs1.Content = null; Assert.Equal(bs0, bs1); bs0 = TestHelper.CreateBeginSession(0, 0, ts); bs1 = TestHelper.CreateBeginSession(0, 0, ts); bs1.Content = null; Assert.NotEqual(bs0, bs1); Assert.NotEqual(bs1, bs0); EndSession es1 = TestHelper.CreateEndSession(0, ts); EndSession es2 = TestHelper.CreateEndSession(0, ts); Assert.Equal(es1, es2); es1.Content = null; es2.Content = null; Assert.Equal(es1, es2); es1 = TestHelper.CreateEndSession(0, ts); es2 = TestHelper.CreateEndSession(0, ts); es1.Content = null; Assert.NotEqual(es1, es2); Assert.NotEqual(es2, es1); UpdateSession us1 = TestHelper.CreateUpdateSession(0, 0, ts); UpdateSession us2 = TestHelper.CreateUpdateSession(0, 0, ts); Assert.Equal(us1, us2); us1.Content = null; us2.Content = null; Assert.Equal(us1, us2); us1 = TestHelper.CreateUpdateSession(0, 0); us2 = TestHelper.CreateUpdateSession(0, 0); us2.Content = null; Assert.NotEqual(us1, us2); Assert.NotEqual(us2, us1); }
public void SerializingEntitiesSession() { BeginSession bs = TestHelper.CreateBeginSession(0, 0); String s1 = JsonConvert.SerializeObject(bs); BeginSession bs2 = JsonConvert.DeserializeObject <BeginSession>(s1); Assert.Equal(bs.Content, bs2.Content); EndSession es = TestHelper.CreateEndSession(0); String s2 = JsonConvert.SerializeObject(es); EndSession es2 = JsonConvert.DeserializeObject <EndSession>(s2); Assert.Equal(es.Content, es2.Content); UpdateSession us = TestHelper.CreateUpdateSession(0, 0); String s3 = JsonConvert.SerializeObject(us); UpdateSession us2 = JsonConvert.DeserializeObject <UpdateSession>(s3); Assert.Equal(us.Content, us2.Content); }
/// <summary> /// Creates the data structures for front-channel and back-channel sign-out notifications. /// </summary> /// <param name="endSession"></param> /// <returns></returns> protected virtual async Task <(IEnumerable <string> frontChannel, IEnumerable <BackChannelLogoutModel> backChannel)> GetClientEndSessionUrlsAsync(EndSession endSession) { var frontChannelUrls = new List <string>(); var backChannelLogouts = new List <BackChannelLogoutModel>(); foreach (var clientId in endSession.ClientIds) { var client = await ClientStore.FindEnabledClientByIdAsync(clientId); if (client != null) { if (client.FrontChannelLogoutUri.IsPresent()) { var url = client.FrontChannelLogoutUri; // add session id if required if (client.ProtocolType == ProtocolTypes.OpenIdConnect) { if (client.FrontChannelLogoutSessionRequired) { url = url.AddQueryString(OidcConstants.EndSessionRequest.Sid, endSession.SessionId); url = url.AddQueryString(OidcConstants.EndSessionRequest.Issuer, Context.HttpContext.GetIdentityServerIssuerUri()); } } else if (client.ProtocolType == ProtocolTypes.WsFederation) { url = url.AddQueryString(Constants.WsFedSignOut.LogoutUriParameterName, Constants.WsFedSignOut.LogoutUriParameterValue); } frontChannelUrls.Add(url); } if (client.BackChannelLogoutUri.IsPresent()) { var back = new BackChannelLogoutModel { ClientId = clientId, LogoutUri = client.BackChannelLogoutUri, SubjectId = endSession.SubjectId, SessionId = endSession.SessionId, SessionIdRequired = client.BackChannelLogoutSessionRequired }; backChannelLogouts.Add(back); } } } if (frontChannelUrls.Any()) { var msg = frontChannelUrls.Aggregate((x, y) => x + ", " + y); Logger.LogDebug("Client front-channel logout URLs: {0}", msg); } else { Logger.LogDebug("No client front-channel logout URLs"); } if (backChannelLogouts.Any()) { var msg = backChannelLogouts.Select(x => x.LogoutUri).Aggregate((x, y) => x + ", " + y); Logger.LogDebug("Client back-channel logout URLs: {0}", msg); } else { Logger.LogDebug("No client back-channel logout URLs"); } return(frontChannelUrls, backChannelLogouts); }
public static EndSession CreateEndSession(int index, long?timestamp = null) { EndSession es = new EndSession(v[index + 0], v[index + 1], timestamp); return(es); }
// Invoke the EndSession notification event private void OnEndSession() { EndSession?.Invoke(); }