File tree Expand file tree Collapse file tree
Features/Authorization/Services
Infrastructure/Common/Settings Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,10 +29,12 @@ public async Task StartAsync(CancellationToken cancellationToken)
2929 foreach ( var clientSettings in _clientSettings . Clients )
3030 {
3131 var resolvedClientType = ResolveClientType ( clientSettings ) ;
32+ var resolvedClientSecret = ResolveClientSecret ( clientSettings , resolvedClientType ) ;
3233 var applicationDescriptor = new OpenIddictApplicationDescriptor
3334 {
3435 ClientId = clientSettings . ClientId ,
3536 ClientType = resolvedClientType ,
37+ ClientSecret = resolvedClientSecret ,
3638 ConsentType = ConsentTypes . Explicit ,
3739 DisplayName = clientSettings . DisplayName ,
3840 Permissions =
@@ -103,5 +105,21 @@ private static string ResolveClientType(ClientSettingsOptions clientSettings)
103105 $ "Unsupported OpenIddict client type '{ clientSettings . ClientType } ' for client '{ clientSettings . ClientId } '.")
104106 } ;
105107 }
108+
109+ private static string ? ResolveClientSecret ( ClientSettingsOptions clientSettings , string resolvedClientType )
110+ {
111+ if ( resolvedClientType == ClientTypes . Public )
112+ {
113+ return null ;
114+ }
115+
116+ if ( ! string . IsNullOrWhiteSpace ( clientSettings . ClientSecret ) )
117+ {
118+ return clientSettings . ClientSecret ;
119+ }
120+
121+ throw new InvalidOperationException (
122+ $ "Client '{ clientSettings . ClientId } ' is configured as confidential but has no client secret.") ;
123+ }
106124 }
107125}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ public class ClientSettingsOptions
99 {
1010 public string ClientId { get ; set ; } = string . Empty ;
1111 public string ClientType { get ; set ; } = string . Empty ;
12+ public string ClientSecret { get ; set ; } = string . Empty ;
1213 public string DisplayName { get ; set ; } = string . Empty ;
1314 public List < string > RedirectUris { get ; set ; } = [ ] ;
1415 public List < string > PostLogoutRedirectUris { get ; set ; } = [ ] ;
You can’t perform that action at this time.
0 commit comments