diff --git a/Directory.Build.props b/Directory.Build.props
index deb1a75f..8db769a5 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -69,7 +69,7 @@
Note: OpenIddict uses PolySharp to dynamically generate polyfills for types that are not available on
some of the targeted TFMs (e.g Index, Range or nullable attributes on .NET Framework/.NET Standard).
-->
-
diff --git a/Packages.props b/Packages.props
index e74a3c3b..bf2da24f 100644
--- a/Packages.props
+++ b/Packages.props
@@ -12,45 +12,45 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs
index 3245ff2d..76becfef 100644
--- a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs
+++ b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs
@@ -48,6 +48,7 @@ namespace OpenIddict.Client.WebIntegration.Generators
var template = Template.Parse(@"#nullable enable
using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
@@ -196,7 +197,7 @@ public partial class OpenIddictClientWebIntegrationBuilder
///
/// The redirection URI.
/// The instance.
- public {{ provider.name }} SetRedirectUri(string address)
+ public {{ provider.name }} SetRedirectUri([StringSyntax(StringSyntaxAttribute.Uri)] string address)
{
if (string.IsNullOrEmpty(address))
{
diff --git a/src/OpenIddict.Abstractions/Caches/IOpenIddictApplicationCache.cs b/src/OpenIddict.Abstractions/Caches/IOpenIddictApplicationCache.cs
index 74ec738c..2f336326 100644
--- a/src/OpenIddict.Abstractions/Caches/IOpenIddictApplicationCache.cs
+++ b/src/OpenIddict.Abstractions/Caches/IOpenIddictApplicationCache.cs
@@ -4,6 +4,8 @@
* the license and the contributors participating to this project.
*/
+using System.Diagnostics.CodeAnalysis;
+
namespace OpenIddict.Abstractions;
///
@@ -48,7 +50,8 @@ public interface IOpenIddictApplicationCache where TApplication :
/// The redirect_uri associated with the applications.
/// The that can be used to abort the operation.
/// The client applications corresponding to the specified redirect_uri.
- IAsyncEnumerable FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken);
+ IAsyncEnumerable FindByPostLogoutRedirectUriAsync(
+ [StringSyntax(StringSyntaxAttribute.Uri)] string address, CancellationToken cancellationToken);
///
/// Retrieves all the applications associated with the specified redirect_uri.
@@ -56,7 +59,8 @@ public interface IOpenIddictApplicationCache where TApplication :
/// The redirect_uri associated with the applications.
/// The that can be used to abort the operation.
/// The client applications corresponding to the specified redirect_uri.
- IAsyncEnumerable FindByRedirectUriAsync(string address, CancellationToken cancellationToken);
+ IAsyncEnumerable FindByRedirectUriAsync(
+ [StringSyntax(StringSyntaxAttribute.Uri)] string address, CancellationToken cancellationToken);
///
/// Removes the specified application from the cache.
diff --git a/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs b/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs
index fa1b5ee6..37293c92 100644
--- a/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs
+++ b/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs
@@ -6,6 +6,7 @@
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text.Json;
@@ -117,7 +118,8 @@ public interface IOpenIddictApplicationManager
/// The post_logout_redirect_uri associated with the applications.
/// The that can be used to abort the operation.
/// The client applications corresponding to the specified post_logout_redirect_uri.
- IAsyncEnumerable
/// The addresses associated to the endpoint.
/// The instance.
- public OpenIddictServerBuilder SetLogoutEndpointUris(params string[] addresses)
+ public OpenIddictServerBuilder SetLogoutEndpointUris(
+ [StringSyntax(StringSyntaxAttribute.Uri)] params string[] addresses)
{
if (addresses is null)
{
@@ -1382,7 +1388,8 @@ public class OpenIddictServerBuilder
///
/// The addresses associated to the endpoint.
/// The instance.
- public OpenIddictServerBuilder SetRevocationEndpointUris(params string[] addresses)
+ public OpenIddictServerBuilder SetRevocationEndpointUris(
+ [StringSyntax(StringSyntaxAttribute.Uri)] params string[] addresses)
{
if (addresses is null)
{
@@ -1430,7 +1437,8 @@ public class OpenIddictServerBuilder
///
/// The addresses associated to the endpoint.
/// The instance.
- public OpenIddictServerBuilder SetTokenEndpointUris(params string[] addresses)
+ public OpenIddictServerBuilder SetTokenEndpointUris(
+ [StringSyntax(StringSyntaxAttribute.Uri)] params string[] addresses)
{
if (addresses is null)
{
@@ -1478,7 +1486,8 @@ public class OpenIddictServerBuilder
///
/// The addresses associated to the endpoint.
/// The instance.
- public OpenIddictServerBuilder SetUserinfoEndpointUris(params string[] addresses)
+ public OpenIddictServerBuilder SetUserinfoEndpointUris(
+ [StringSyntax(StringSyntaxAttribute.Uri)] params string[] addresses)
{
if (addresses is null)
{
@@ -1526,7 +1535,8 @@ public class OpenIddictServerBuilder
///
/// The addresses associated to the endpoint.
/// The instance.
- public OpenIddictServerBuilder SetVerificationEndpointUris(params string[] addresses)
+ public OpenIddictServerBuilder SetVerificationEndpointUris(
+ [StringSyntax(StringSyntaxAttribute.Uri)] params string[] addresses)
{
if (addresses is null)
{
diff --git a/src/OpenIddict.Server/OpenIddictServerEvents.Authentication.cs b/src/OpenIddict.Server/OpenIddictServerEvents.Authentication.cs
index f4cc8266..caeaa5d4 100644
--- a/src/OpenIddict.Server/OpenIddictServerEvents.Authentication.cs
+++ b/src/OpenIddict.Server/OpenIddictServerEvents.Authentication.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Diagnostics.CodeAnalysis;
using System.Security.Claims;
namespace OpenIddict.Server;
@@ -67,6 +68,7 @@ public static partial class OpenIddictServerEvents
/// If it's not provided by the client, it must be set by
/// the user code by calling .
///
+ [StringSyntax(StringSyntaxAttribute.Uri)]
public string? RedirectUri { get; private set; }
///
@@ -79,7 +81,7 @@ public static partial class OpenIddictServerEvents
/// Populates the property with the specified redirect_uri.
///
/// The redirect_uri to use when redirecting the user agent.
- public void SetRedirectUri(string address)
+ public void SetRedirectUri([StringSyntax(StringSyntaxAttribute.Uri)] string address)
{
if (string.IsNullOrEmpty(address))
{
diff --git a/src/OpenIddict.Server/OpenIddictServerEvents.Session.cs b/src/OpenIddict.Server/OpenIddictServerEvents.Session.cs
index ba6589e3..97051d7c 100644
--- a/src/OpenIddict.Server/OpenIddictServerEvents.Session.cs
+++ b/src/OpenIddict.Server/OpenIddictServerEvents.Session.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Diagnostics.CodeAnalysis;
using System.Security.Claims;
namespace OpenIddict.Server;
@@ -65,6 +66,7 @@ public static partial class OpenIddictServerEvents
///
/// Gets the post_logout_redirect_uri specified by the client application.
///
+ [StringSyntax(StringSyntaxAttribute.Uri)]
public string? PostLogoutRedirectUri { get; private set; }
///
@@ -77,7 +79,7 @@ public static partial class OpenIddictServerEvents
/// Populates the property with the specified redirect_uri.
///
/// The post_logout_redirect_uri to use when redirecting the user agent.
- public void SetPostLogoutRedirectUri(string address)
+ public void SetPostLogoutRedirectUri([StringSyntax(StringSyntaxAttribute.Uri)] string address)
{
if (string.IsNullOrEmpty(address))
{
diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs
index 96e295ef..a8a99398 100644
--- a/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs
+++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs
@@ -6,6 +6,7 @@
using System.Collections.Immutable;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Security.Claims;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -513,7 +514,7 @@ public static partial class OpenIddictServerHandlers
return;
}
- async ValueTask ValidatePostLogoutRedirectUriAsync(string address)
+ async ValueTask ValidatePostLogoutRedirectUriAsync([StringSyntax(StringSyntaxAttribute.Uri)] string address)
{
// To be considered valid, a post_logout_redirect_uri must correspond to an existing client application
// that was granted the ept:logout permission, unless endpoint permissions checking was explicitly disabled.
@@ -753,7 +754,8 @@ public static partial class OpenIddictServerHandlers
return;
}
- async ValueTask ValidateAuthorizedParty(ClaimsPrincipal principal, string address)
+ async ValueTask ValidateAuthorizedParty(ClaimsPrincipal principal,
+ [StringSyntax(StringSyntaxAttribute.Uri)] string address)
{
// To be considered valid, one of the clients matching the specified post_logout_redirect_uri
// must be listed either as an audience or as a presenter in the identity token hint.
diff --git a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs
index f376c32b..0023700f 100644
--- a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs
+++ b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs
@@ -456,7 +456,7 @@ public class OpenIddictValidationBuilder
///
/// The issuer address.
/// The instance.
- public OpenIddictValidationBuilder SetIssuer(string address)
+ public OpenIddictValidationBuilder SetIssuer([StringSyntax(StringSyntaxAttribute.Uri)] string address)
{
if (string.IsNullOrEmpty(address))
{
diff --git a/src/OpenIddict.Validation/OpenIddictValidationRetriever.cs b/src/OpenIddict.Validation/OpenIddictValidationRetriever.cs
index 26d07900..d07f0d24 100644
--- a/src/OpenIddict.Validation/OpenIddictValidationRetriever.cs
+++ b/src/OpenIddict.Validation/OpenIddictValidationRetriever.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Diagnostics.CodeAnalysis;
using Microsoft.IdentityModel.Protocols;
namespace OpenIddict.Validation;
@@ -26,7 +27,8 @@ public class OpenIddictValidationRetriever : IConfigurationRetrieverThe retriever used by IdentityModel.
/// The that can be used to abort the operation.
/// The OpenID Connect server configuration retrieved from the remote server.
- async Task IConfigurationRetriever.GetConfigurationAsync(string address, IDocumentRetriever retriever, CancellationToken cancel)
+ async Task IConfigurationRetriever.GetConfigurationAsync(
+ [StringSyntax(StringSyntaxAttribute.Uri)] string address, IDocumentRetriever retriever, CancellationToken cancel)
{
if (string.IsNullOrEmpty(address))
{