/// <summary> /// Creates the item. /// </summary> /// <param name="item">The item.</param> /// <param name="clientId">The client identifier.</param> /// <param name="subjectId">The subject identifier.</param> /// <param name="created">The created.</param> /// <param name="lifetime">The lifetime.</param> /// <returns></returns> protected async Task <string> CreateItemAsync(T item, string clientId, string subjectId, DateTime created, int lifetime) { var handle = await _handleGenerationService.GenerateAsync(); await StoreItemAsync(handle, item, clientId, subjectId, created, created.AddSeconds(lifetime)); return(handle); }
/// <summary> /// Stores the device authorization request. /// </summary> /// <param name="userCode">The user code.</param> /// <param name="data">The data.</param> /// <returns></returns> public async Task <string> StoreDeviceAuthorizationAsync(string userCode, DeviceCode data) { var deviceCode = await _handleGenerationService.GenerateAsync(); await _store.StoreDeviceAuthorizationAsync(deviceCode.Sha256(), userCode.Sha256(), data); return(deviceCode); }
/// <summary> /// Stores the device authorization request. /// </summary> /// <param name="userCode">The user code.</param> /// <param name="data">The data.</param> /// <returns></returns> public async Task <string> StoreDeviceAuthorizationAsync(string userCode, DeviceCode data) { using var activity = Tracing.StoreActivitySource.StartActivity("DefaultDeviceFlowCodeService.SendLogoutNotifStoreDeviceAuthorization"); var deviceCode = await _handleGenerationService.GenerateAsync(); await _store.StoreDeviceAuthorizationAsync(deviceCode.Sha256(), userCode.Sha256(), data); return(deviceCode); }
/// <inheritdoc/> public async Task <string> WriteAsync(Message <NameValueCollection> message) { // since this store is trusted and the JWT request processing has provided redundant entries // in the NameValueCollection, we are removing the JWT "request_uri" param so that when they // are reloaded/revalidated we don't re-trigger outbound requests. we could possibly do the // same for the "request" param, but it's less of a concern (as it's just a signature check). message.Data.Remove(OidcConstants.AuthorizeRequest.RequestUri); var key = await _handleGenerationService.GenerateAsync(); var cacheKey = $"{CacheKeyPrefix}-{key}"; var json = ObjectSerializer.ToString(message); var options = new DistributedCacheEntryOptions(); options.SetSlidingExpiration(Constants.DefaultCacheDuration); await _distributedCache.SetStringAsync(cacheKey, json, options); return(key); }