IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

How to get which client was used

Open imsmart-tech opened this issue 8 years ago • 2 comments

Not really an issue but trying to understand some concepts. I implemented most of IdentityServer4 following the Quickstarts and it works well. Here is my case: I wish to give a secure access to an API on the same URL than the web site, which also has a login.

So on the web site, I want users to be able to access the application as well as the API. However for external application which should only access the API, I wish they cannot access the rest of the application.

I understand I could do this by having 2 webs: one for the application, one for the API but I wish to have them both on the same URL.

So I thought I would simply need 2 different clients connected to the same users database (using ASP.NET Identity):

 new Client
 {
     ClientId = "SecureAPI",
     ClientName = "Secure API",
     AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,

     ClientSecrets =
     {
         new Secret("secret".Sha256())
     },
     RedirectUris = { "http://localhost:5002/signin-oidc" },
     PostLogoutRedirectUris = { "http://localhost:5002/signout-callback-oidc" },

     AllowedScopes = { "sapi" }
},

 // OpenID Connect hybrid flow and client credentials client (MVC)
 new Client
 {
     ClientId = "mvc",
     ClientName = "MVC Client",
     AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,

     RequireConsent = false,

     ClientSecrets =
     {
         new Secret("secret".Sha256())
     },

     RedirectUris = { "http://localhost:5002/signin-oidc" },
     PostLogoutRedirectUris = { "http://localhost:5002/signout-callback-oidc" },

     AllowedScopes =
     {
         IdentityServerConstants.StandardScopes.OpenId,
         IdentityServerConstants.StandardScopes.Profile,
         "sapi"
     },
     AllowOfflineAccess = true
 }

So my idea is that the client mvc can access the application and API while sapi client can only access the API and not the application. Any user can be used with client "mvc" or "sapi".

The problem is how do I discriminate one client from the other?

imsmart-tech avatar Jan 12 '18 00:01 imsmart-tech

This seems to be a general question about IdentityServer - not a bug report or an issue.

Please use one of the our free or commercial support options

See here for more details.

Thanks!

leastprivilege avatar Jan 12 '18 07:01 leastprivilege

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 13 '20 19:01 lock[bot]