public InteractiveClient(SimpleClientDetails clientDetails) : base(clientDetails)
 {
     this.AllowedGrantTypes  = GrantTypes.Code;
     this.RequireConsent     = false;
     this.RequirePkce        = true;
     this.AllowOfflineAccess = true;
 }
        public IEnumerable <Client> GetClients()
        {
            var output = new List <Client>();

            if (this.InstanceValid())
            {
                foreach (var i in this.instance.ClientDetails)
                {
                    var clientTypeEnum = i.ClientType.ToClientTypeFromString();

                    var clientDetails = new SimpleClientDetails()
                    {
                        ClientId          = i.ClientId,
                        Secret            = i.Secret,
                        ClientName        = i.ClientName,
                        BaseUri           = i.BaseUri,
                        RedirectUris      = i.RedirectUris,
                        LogoutRedirectUri = i.LogoutRedirectUri,
                        AllowedScopes     = i.AllowedScopes,
                    };

                    switch (clientTypeEnum)
                    {
                    case ClientType.BrowserClient:
                        output.Add(new BrowserClient(clientDetails));
                        break;

                    case ClientType.InteractiveClient:
                        output.Add(new InteractiveClient(clientDetails));
                        break;

                    case ClientType.NonInteractiveClient:
                        output.Add(new NonInteractiveClient(clientDetails));
                        break;

                    default:
                        throw new Exception("Unknown ClientType");
                    }
                }
            }

            return(output);
        }
        public SimpleClientBuilderBase(SimpleClientDetails clientDetails)
        {
            this._clientDetails = clientDetails;

            this.ClientId   = clientDetails.ClientId;
            this.ClientName = clientDetails.ClientName ?? clientDetails.ClientId;

            if (clientDetails.RedirectUris != null && clientDetails.RedirectUris.Count > 0)
            {
                this.RedirectUris = new List <String>();
                foreach (var redirectUri in clientDetails.RedirectUris)
                {
                    this.RedirectUris.Add(this.GetFullUri(clientDetails.BaseUri, redirectUri));
                }
            }

            this.PostLogoutRedirectUris = new List <String>
            {
                this.GetFullUri(clientDetails.BaseUri, clientDetails.LogoutRedirectUri)
            };

            if (String.IsNullOrEmpty(clientDetails.Secret) == false)
            {
                this.ClientSecrets = new List <Secret>();
                this.ClientSecrets.Add(new Secret(clientDetails.Secret.Sha256()));
            }

            this.AllowedScopes = new List <String>
            {
                IdentityServerConstants.StandardScopes.OpenId,
                IdentityServerConstants.StandardScopes.Profile,
                IdentityServerConstants.StandardScopes.Email,
            };

            if (clientDetails.AllowedScopes != null && clientDetails.AllowedScopes.Count > 0)
            {
                foreach (var scope in clientDetails.AllowedScopes)
                {
                    this.AllowedScopes.Add(scope);
                }
            }
        }
 public NonInteractiveClient(SimpleClientDetails clientDetails) : base(clientDetails)
 {
     // no interactive user, use the clientid/secret for authentication
     AllowedGrantTypes = GrantTypes.ClientCredentials;
 }
 public BrowserClient(SimpleClientDetails clientDetails) : base(clientDetails)
 {
     this.AllowedGrantTypes           = GrantTypes.Implicit;
     this.AllowAccessTokensViaBrowser = true;
     this.AllowOfflineAccess          = true;
 }