diff --git a/.idea/.idea.Graeae/.idea/.gitignore b/.idea/.idea.Graeae/.idea/.gitignore new file mode 100644 index 0000000..4746bbf --- /dev/null +++ b/.idea/.idea.Graeae/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/contentModel.xml +/projectSettingsUpdater.xml +/.idea.Graeae.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Graeae.AspNet.Analyzer/Graeae.AspNet.Analyzer.csproj b/Graeae.AspNet.Analyzer/Graeae.AspNet.Analyzer.csproj index 02d0e7d..f1ba352 100644 --- a/Graeae.AspNet.Analyzer/Graeae.AspNet.Analyzer.csproj +++ b/Graeae.AspNet.Analyzer/Graeae.AspNet.Analyzer.csproj @@ -25,7 +25,7 @@ Release notes can be found at https://github.com/gregsdennis/Graeae true Graeae.AspNet.xml - 0.1.0-preview2 + 0.1.0-preview3 0.1.0 0.1.0.0 false diff --git a/Graeae.AspNet/Graeae.AspNet.csproj b/Graeae.AspNet/Graeae.AspNet.csproj index 96a68b1..f98e6a6 100644 --- a/Graeae.AspNet/Graeae.AspNet.csproj +++ b/Graeae.AspNet/Graeae.AspNet.csproj @@ -1,7 +1,7 @@  - net8.0 + net8.0 enable enable Graeae.AspNet @@ -17,7 +17,7 @@ Release notes can be found at https://github.com/gregsdennis/Graeae true Graeae.AspNet.xml - 0.1.0-preview1 + 0.1.0-preview2 0.1.0 0.1.0.0 true diff --git a/Graeae.Models/Graeae.Models.csproj b/Graeae.Models/Graeae.Models.csproj index 376de15..8ce6b42 100644 --- a/Graeae.Models/Graeae.Models.csproj +++ b/Graeae.Models/Graeae.Models.csproj @@ -19,9 +19,9 @@ $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../RELEASE_NOTES.md")) true Graeae.Models.xml - 0.3.4 - 0.3.4 - 0.3.4.0 + 0.3.5 + 0.3.5 + 0.3.5.0 true snupkg true diff --git a/Graeae.Models/OAuthFlow.cs b/Graeae.Models/OAuthFlow.cs index 256a9d9..c0f94c0 100644 --- a/Graeae.Models/OAuthFlow.cs +++ b/Graeae.Models/OAuthFlow.cs @@ -21,11 +21,11 @@ public class OAuthFlow : IRefTargetContainer /// /// Gets the authorization URL. /// - public Uri AuthorizationUrl { get; } + public Uri? AuthorizationUrl { get; set; } /// /// Gets the token URL. /// - public Uri TokenUrl { get; } + public Uri? TokenUrl { get; set; } /// /// Gets or sets the refresh token URL. /// @@ -42,13 +42,9 @@ public class OAuthFlow : IRefTargetContainer /// /// Creates a new /// - /// The authorization URL - /// The token URL /// The scopes - public OAuthFlow(Uri authorizationUrl, Uri tokenUrl, Dictionary scopes) + public OAuthFlow(Dictionary scopes) { - AuthorizationUrl = authorizationUrl; - TokenUrl = tokenUrl; Scopes = scopes; } @@ -58,10 +54,10 @@ internal static OAuthFlow FromNode(JsonNode? node) throw new JsonException("Expected an object"); var flow = new OAuthFlow( - obj.ExpectUri("authorizationUrl", "oauth flow"), - obj.ExpectUri("tokenUrl", "oauth flow"), obj.ExpectMap("scopes", "oauth flow", x => x is JsonValue v && v.TryGetValue(out string? s) ? s : throw new JsonException("scopes must be strings"))) { + AuthorizationUrl = obj.MaybeUri("authorizationUrl", "oauth flow"), + TokenUrl = obj.MaybeUri("tokenUrl", "oauth flow"), RefreshUrl = obj.MaybeUri("refreshUrl", "oauth flow"), ExtensionData = ExtensionData.FromNode(obj) }; @@ -75,11 +71,10 @@ internal static OAuthFlow FromNode(JsonNode? node) { if (flow == null) return null; - var obj = new JsonObject - { - ["authorizationUrl"] = flow.AuthorizationUrl.ToString(), - ["tokenUrl"] = flow.TokenUrl.ToString() - }; + var obj = new JsonObject(); + obj.MaybeAdd("authorizationUrl", flow.AuthorizationUrl?.ToString()); + obj.MaybeAdd("tokenUrl", flow.TokenUrl?.ToString()); + obj.MaybeAdd("refreshUrl", flow.RefreshUrl?.ToString()); var scopes = new JsonObject(); foreach (var kvp in flow.Scopes) @@ -88,7 +83,6 @@ internal static OAuthFlow FromNode(JsonNode? node) } obj.Add("scopes", scopes); - obj.MaybeAdd("refreshUrl", flow.RefreshUrl?.ToString()); obj.AddExtensions(flow.ExtensionData); return obj; diff --git a/Graeae.Models/OAuthFlowCollection.cs b/Graeae.Models/OAuthFlowCollection.cs index e6597e1..8ea6e52 100644 --- a/Graeae.Models/OAuthFlowCollection.cs +++ b/Graeae.Models/OAuthFlowCollection.cs @@ -52,6 +52,18 @@ internal static OAuthFlowCollection FromNode(JsonNode? node) AuthorizationCode = obj.Maybe("authorizationCode", OAuthFlow.FromNode), ExtensionData = ExtensionData.FromNode(obj) }; + + if (flows.Implicit is not null && flows.Implicit.AuthorizationUrl is null) + throw new JsonException($"`authorizationUrl` is required for implicit oauth flow object"); + if (flows.Password is not null && flows.Password.TokenUrl is null) + throw new JsonException($"`tokenUrl` is required for password oauth flow object"); + if (flows.ClientCredentials is not null && flows.ClientCredentials.TokenUrl is null) + throw new JsonException($"`tokenUrl` is required for clientCredentials oauth flow object"); + if (flows.AuthorizationCode is not null) + { + if (flows.AuthorizationCode.AuthorizationUrl is null) throw new JsonException($"`authorizationUrl` is required for authorizationCode oauth flow object"); + if (flows.AuthorizationCode.TokenUrl is null) throw new JsonException($"`tokenUrl` is required for authorizationCode oauth flow object"); + } obj.ValidateNoExtraKeys(KnownKeys, flows.ExtensionData?.Keys); diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 6b47132..e4ca06f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,5 @@ + + [0.3.4](https://github.com/gregsdennis/Graeae/commit/f3f6bb0c4ec29879f8fb24573900f51f61e0bfae) (v0.3.3 redacted) - Added .Net Standard 2.0 support.