/// <inheritdoc/> public async ValueTask HandleAsync(ProcessRequestContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var notification = new ValidateDeviceRequestContext(context.Transaction); await _dispatcher.DispatchAsync(notification); if (notification.IsRequestHandled) { context.HandleRequest(); return; } else if (notification.IsRequestSkipped) { context.SkipRequest(); return; } else if (notification.IsRejected) { context.Reject( error: notification.Error ?? Errors.InvalidRequest, description: notification.ErrorDescription, uri: notification.ErrorUri); return; } context.Logger.LogInformation(SR.GetResourceString(SR.ID7055)); }
/// <summary> /// Processes the event. /// </summary> /// <param name="context">The context associated with the event to process.</param> /// <returns> /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// </returns> public async ValueTask HandleAsync([NotNull] ProcessRequestContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.EndpointType != OpenIddictServerEndpointType.Userinfo) { return; } var notification = new ExtractUserinfoRequestContext(context.Transaction); await _provider.DispatchAsync(notification); if (notification.IsRequestHandled) { context.HandleRequest(); return; } else if (notification.IsRequestSkipped) { context.SkipRequest(); return; } else if (notification.IsRejected) { context.Reject( error: notification.Error ?? Errors.InvalidRequest, description: notification.ErrorDescription, uri: notification.ErrorUri); return; } if (notification.Request == null) { throw new InvalidOperationException(new StringBuilder() .Append("The userinfo request was not correctly extracted. To extract userinfo requests, ") .Append("create a class implementing 'IOpenIddictServerHandler<ExtractUserinfoRequestContext>' ") .AppendLine("and register it using 'services.AddOpenIddict().AddServer().AddEventHandler()'.") .ToString()); } context.Logger.LogInformation("The userinfo request was successfully extracted: {Request}.", notification.Request); }
/// <summary> /// Processes the event. /// </summary> /// <param name="context">The context associated with the event to process.</param> /// <returns> /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// </returns> public async ValueTask HandleAsync([NotNull] ProcessRequestContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.EndpointType != OpenIddictServerEndpointType.Logout) { return; } var notification = new ValidateLogoutRequestContext(context.Transaction); await _provider.DispatchAsync(notification); if (notification.IsRequestHandled) { context.HandleRequest(); return; } else if (notification.IsRequestSkipped) { context.SkipRequest(); return; } else if (notification.IsRejected) { context.Reject( error: notification.Error ?? Errors.InvalidRequest, description: notification.ErrorDescription, uri: notification.ErrorUri); return; } if (!string.IsNullOrEmpty(notification.PostLogoutRedirectUri)) { // Store the validated post_logout_redirect_uri as an environment property. context.Transaction.Properties[Properties.ValidatedPostLogoutRedirectUri] = notification.PostLogoutRedirectUri; } context.Logger.LogInformation("The logout request was successfully validated."); }
/// <summary> /// Processes the event. /// </summary> /// <param name="context">The context associated with the event to process.</param> /// <returns> /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// </returns> public async ValueTask HandleAsync([NotNull] ProcessRequestContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.EndpointType != OpenIddictServerEndpointType.Userinfo) { return; } var notification = new ValidateUserinfoRequestContext(context.Transaction); await _provider.DispatchAsync(notification); // Store the context object in the transaction so it can be later retrieved by handlers // that want to access the principal without triggering a new validation process. context.Transaction.SetProperty(typeof(ValidateUserinfoRequestContext).FullName, notification); if (notification.IsRequestHandled) { context.HandleRequest(); return; } else if (notification.IsRequestSkipped) { context.SkipRequest(); return; } else if (notification.IsRejected) { context.Reject( error: notification.Error ?? Errors.InvalidRequest, description: notification.ErrorDescription, uri: notification.ErrorUri); return; } context.Logger.LogInformation("The userinfo request was successfully validated."); }
/// <summary> /// Processes the event. /// </summary> /// <param name="context">The context associated with the event to process.</param> /// <returns> /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// </returns> public async ValueTask HandleAsync([NotNull] ProcessRequestContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.EndpointType != OpenIddictServerEndpointType.Userinfo) { return; } var notification = new ValidateUserinfoRequestContext(context.Transaction); await _provider.DispatchAsync(notification); if (notification.IsRequestHandled) { context.HandleRequest(); return; } else if (notification.IsRequestSkipped) { context.SkipRequest(); return; } else if (notification.IsRejected) { context.Reject( error: notification.Error ?? Errors.InvalidRequest, description: notification.ErrorDescription, uri: notification.ErrorUri); return; } // Store the security principal extracted from the authorization code/refresh token as an environment property. context.Transaction.Properties[Properties.AmbientPrincipal] = notification.Principal; context.Logger.LogInformation("The userinfo request was successfully validated."); }
/// <inheritdoc/> public async ValueTask HandleAsync(ProcessRequestContext context) { if (context is null) { throw new ArgumentNullException(nameof(context)); } var notification = new ValidateUserinfoRequestContext(context.Transaction); await _dispatcher.DispatchAsync(notification); // Store the context object in the transaction so it can be later retrieved by handlers // that want to access the principal without triggering a new validation process. context.Transaction.SetProperty(typeof(ValidateUserinfoRequestContext).FullName !, notification); if (notification.IsRequestHandled) { context.HandleRequest(); return; } else if (notification.IsRequestSkipped) { context.SkipRequest(); return; } else if (notification.IsRejected) { context.Reject( error: notification.Error ?? Errors.InvalidRequest, description: notification.ErrorDescription, uri: notification.ErrorUri); return; } context.Logger.LogInformation(SR.GetResourceString(SR.ID6130)); }