public async Task <IActionResult> GetUserApplications([FromRoute] string userId) { var userGrants = await _persistedGrantService.GetAllGrantsAsync(userId); var clients = new List <UserClientInfo>(); foreach (var grant in userGrants) { var client = await _clientStore.FindClientByIdAsync(grant.ClientId); if (client != null) { clients.Add(new UserClientInfo { ClientId = client.ClientId, ClientName = client.ClientName, ClientUri = client.ClientUri, Description = client.Description, LogoUri = client.LogoUri, RequireConsent = client.RequireConsent, AllowRememberConsent = client.AllowRememberConsent, Enabled = client.Enabled, CreatedAt = grant.CreationTime, ExpiresAt = grant.Expiration, Scopes = grant.Scopes }); } } return(Ok(clients.ToResultSet())); }
public async Task <IActionResult> Logout(LogoutViewModel model) { var idp = User?.FindFirst(JwtClaimTypes.IdentityProvider)?.Value; var subjectId = User?.FindFirst(JwtClaimTypes.Subject)?.Value; if (idp != null && idp != IdentityServerConstants.LocalIdentityProvider) { if (model.LogoutId == null) { // if there's no current logout context, we need to create one // this captures necessary info from the current logged in user // before we signout and redirect away to the external IdP for signout model.LogoutId = await _interaction.CreateLogoutContextAsync(); } string url = "/Account/Logout?logoutId=" + model.LogoutId; try { await _signInManager.SignOutAsync(); // await HttpContext.Authentication.SignOutAsync(idp, new AuthenticationProperties { RedirectUri = url }); } catch (NotSupportedException) { } } // delete authentication cookie await _signInManager.SignOutAsync(); // set this so UI rendering sees an anonymous user HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity()); // get context information (client name, post logout redirect URI and iframe for federated signout) var logout = await _interaction.GetLogoutContextAsync(model.LogoutId); var vm = new LoggedOutViewModel { PostLogoutRedirectUri = logout?.PostLogoutRedirectUri != null ? logout?.PostLogoutRedirectUri : "/", AutomaticRedirectAfterSignOut = true, ClientName = logout?.ClientId, SignOutIframeUrl = logout?.SignOutIFrameUrl }; if (subjectId != null) { var grants = await _persistedGrantService.GetAllGrantsAsync(subjectId); foreach (var grant in grants) { await _persistedGrantService.RemoveAllGrantsAsync(subjectId, grant.ClientId); } } return(View("LoggedOut", vm)); }
public async Task <IEnumerable <Grant> > GetAllUserGrantsAsync() { var user = await _userSession.GetUserAsync(); if (user != null) { var subject = user.GetSubjectId(); return(await _grants.GetAllGrantsAsync(subject)); } return(Enumerable.Empty <Grant>()); }
public async Task <IEnumerable <Consent> > GetAllUserConsentsAsync() { var user = await _context.HttpContext.GetIdentityServerUserAsync(); if (user != null) { var subject = user.GetSubjectId(); return(await _grants.GetAllGrantsAsync(subject)); } return(Enumerable.Empty <Consent>()); }
public async Task <IEnumerable <Grant> > GetAllUserGrantsAsync() { using var activity = Tracing.ServiceActivitySource.StartActivity("DefaultIdentityServerInteractionService.GetAllUserGrants"); var user = await _userSession.GetUserAsync(); if (user != null) { var subject = user.GetSubjectId(); return(await _grants.GetAllGrantsAsync(subject)); } return(Enumerable.Empty <Grant>()); }
/// <summary> /// Gets all grants for a given subject Id. /// </summary> /// <param name="subjectId">The subject identifier.</param> public Task <IEnumerable <Consent> > GetAllGrantsAsync(string subjectId) => _inner.GetAllGrantsAsync(subjectId);