public static async Task Refresh(CookieValidatePrincipalContext ctx, StudioApplicationConfig cfg) { if (ctx == null) { throw new ArgumentException("ctx is missing from Refresh method"); } if (cfg == null) { throw new ArgumentException("cfg is missing from Refresh method"); } if (ctx.Properties.ExpiresUtc < DateTime.Now) { ctx.RejectPrincipal(); return; } try { var expiresAt = ctx.Properties.Items[".Token.expires_at"]; if (expiresAt != null) { DateTime expTime; bool istime = DateTime.TryParse(expiresAt, out expTime); if (istime && expTime.AddMinutes(-cfg.TokenRefreshEarlyMinutes) < DateTime.Now) { var currentUser = UserHelper.GetCurrentUser(ctx.HttpContext); var client = new StudioClient(cfg, currentUser, Log.Logger); var refreshToken = ctx.Properties.Items[".Token.refresh_token"]; var token = await client.RefreshToken(refreshToken); ctx.Properties.Items[".Token.expires_at"] = token.ExpiresTime.ToString(); ctx.Properties.Items[".Token.access_token"] = token.AccessToken; ctx.Properties.Items[".Token.refresh_token"] = token.RefreshToken; ctx.ShouldRenew = true; } } } catch (Exception e) { Log.Logger.Error("Error Refreshing token {Exception}", e); ctx.RejectPrincipal(); } }
public ProjectsController(StudioApplicationConfig config) { Config = config; }
public FakeProjectsController(StudioApplicationConfig config, ICollaborationService svc) : base(config) { MockService = svc; IsInitialized = false; }
public SessionsController(StudioApplicationConfig config) : base(config) { }
public HomeController(ILogger <HomeController> logger, StudioApplicationConfig config) { _logger = logger; _Config = config; }