From 7ede9c3c68505322c8fa008bfcaf6393cc3875fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Fri, 26 Jan 2024 14:55:03 +0100 Subject: [PATCH 1/3] feat: add v2 beta clients from gRPC (#918) * add new clients * please the upgraded linter * update renove file --- renovate.json | 2 +- src/Directory.Build.props | 4 +- src/Zitadel/Api/Clients.cs | 70 ++++++++++++++++++++--- src/Zitadel/Credentials/ServiceAccount.cs | 24 ++++---- 4 files changed, 75 insertions(+), 25 deletions(-) diff --git a/renovate.json b/renovate.json index aaa61bff..f468720c 100644 --- a/renovate.json +++ b/renovate.json @@ -1,4 +1,4 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["github>smartive/renovate-config", "github>smartive/renovate-config:with-submodules", ":disableMajorUpdates"] + "extends": ["github>smartive/renovate-config", ":disableMajorUpdates"] } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index cc2e09b3..befc1ac2 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -37,7 +37,7 @@ - + diff --git a/src/Zitadel/Api/Clients.cs b/src/Zitadel/Api/Clients.cs index 84c0c228..c25fb6e9 100644 --- a/src/Zitadel/Api/Clients.cs +++ b/src/Zitadel/Api/Clients.cs @@ -5,6 +5,12 @@ using Zitadel.Auth.V1; using Zitadel.Authentication; using Zitadel.Management.V1; +using Zitadel.Oidc.V2beta; +using Zitadel.Org.V2beta; +using Zitadel.Session.V2beta; +using Zitadel.Settings.V2beta; +using Zitadel.System.V1; +using Zitadel.User.V2beta; namespace Zitadel.Api; @@ -13,14 +19,6 @@ namespace Zitadel.Api; /// public static class Clients { - /// - /// Create a service client for the auth service. - /// - /// Options for the client like authorization method. - /// The . - public static AuthService.AuthServiceClient AuthService(Options options) => - GetClient(options); - /// /// Create a service client for the admin service. /// @@ -29,6 +27,14 @@ public static AuthService.AuthServiceClient AuthService(Options options) => public static AdminService.AdminServiceClient AdminService(Options options) => GetClient(options); + /// + /// Create a service client for the auth service. + /// + /// Options for the client like authorization method. + /// The . + public static AuthService.AuthServiceClient AuthService(Options options) => + GetClient(options); + /// /// Create a service client for the management service. /// @@ -37,6 +43,54 @@ public static AdminService.AdminServiceClient AdminService(Options options) => public static ManagementService.ManagementServiceClient ManagementService(Options options) => GetClient(options); + /// + /// Create a service client for the oidc service. + /// + /// Options for the client like authorization method. + /// The . + public static OIDCService.OIDCServiceClient OidcService(Options options) => + GetClient(options); + + /// + /// Create a service client for the organization service. + /// + /// Options for the client like authorization method. + /// The . + public static OrganizationService.OrganizationServiceClient OrganizationService(Options options) => + GetClient(options); + + /// + /// Create a service client for the session service. + /// + /// Options for the client like authorization method. + /// The . + public static SessionService.SessionServiceClient SessionService(Options options) => + GetClient(options); + + /// + /// Create a service client for the settings service. + /// + /// Options for the client like authorization method. + /// The . + public static SettingsService.SettingsServiceClient SettingsService(Options options) => + GetClient(options); + + /// + /// Create a service client for the system service. + /// + /// Options for the client like authorization method. + /// The . + public static SystemService.SystemServiceClient SystemService(Options options) => + GetClient(options); + + /// + /// Create a service client for the user service. + /// + /// Options for the client like authorization method. + /// The . + public static UserService.UserServiceClient UserService(Options options) => + GetClient(options); + private static TClient GetClient(Options options) where TClient : ClientBase { diff --git a/src/Zitadel/Credentials/ServiceAccount.cs b/src/Zitadel/Credentials/ServiceAccount.cs index 1bb5a83f..d077bc3d 100644 --- a/src/Zitadel/Credentials/ServiceAccount.cs +++ b/src/Zitadel/Credentials/ServiceAccount.cs @@ -33,13 +33,13 @@ namespace Zitadel.Credentials /// public record ServiceAccount { - private static readonly HttpClient HttpClient = new(); - /// /// The key type. /// public const string Type = "serviceaccount"; + private static readonly HttpClient HttpClient = new(); + /// /// The user id associated with this service account. /// @@ -204,10 +204,7 @@ private async Task GetSignedJwtAsync(string audience) }, rsa, JwsAlgorithm.RS256, - new Dictionary - { - { "kid", KeyId }, - }); + new Dictionary { { "kid", KeyId }, }); } private async Task GetRsaParametersAsync() @@ -225,12 +222,6 @@ private async Task GetRsaParametersAsync() return DotNetUtilities.ToRSAParameters(keyPair.Private as RsaPrivateCrtKeyParameters); } - private sealed record AccessTokenResponse - { - [JsonPropertyName("access_token")] - public string AccessToken { get; init; } = string.Empty; - } - /// /// Options for the authentication with a . /// @@ -283,8 +274,7 @@ internal string CreateOidcScopes() => ' ', new[] { - "openid", - ApiAccess + "openid", ApiAccess ? ApiAccessScope : string.Empty, } @@ -293,5 +283,11 @@ internal string CreateOidcScopes() => .Union(RequiredRoles.Select(r => $"urn:zitadel:iam:org:project:role:{r}")) .Where(s => !string.IsNullOrWhiteSpace(s))); } + + private sealed record AccessTokenResponse + { + [JsonPropertyName("access_token")] + public string AccessToken { get; init; } = string.Empty; + } } } From c694bdddb1b3982027632dd9fc90177d6f3dfe1c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 20:12:11 +0000 Subject: [PATCH 2/3] fix(deps): update dependency sonaranalyzer.csharp to v9.18.0.83559 --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index befc1ac2..71941bf1 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -42,7 +42,7 @@ Condition="$(MSBuildProjectExtension) == '.csproj'" /> From eb7490faebb0ac556b2c653e1fb44797880c35d3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:59:45 +0000 Subject: [PATCH 3/3] fix(deps): update dependency sonaranalyzer.csharp to v9.19.0.84025 --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 71941bf1..5d0c0157 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -42,7 +42,7 @@ Condition="$(MSBuildProjectExtension) == '.csproj'" />