Esempio n. 1
0
        internal DbPortal CreateDatabasePortal()
        {
            if (this.dbPortal != null)
            {
                return(this.dbPortal);
            }

            if (this.DocDBClient != null)
            {
                this.dbPortal = new DocumentDbPortal(this);
            }
            if (this.JsonServerClient != null)
            {
                this.dbPortal = new JsonServerDbPortal(this);
            }
            Debug.Assert(this.dbPortal != null, "Unsupported type of database.");
            return(this.dbPortal);
        }
        public static IEnumerable <Client> GetClients2(IConfiguration config, Ilog log)
        {
            //log.InsertT_PRT_SYS_LOG("info", "GetClients2");
            var _DbPortal = new DbPortal(new ApplicationDbContext(new DbContextOptions <ApplicationDbContext>(), config), log);

            List <T_PRT_CLIENTS> dbclients = _DbPortal.GetT_PRT_CLIENTS();

            List <Client> _clients = new List <Client>();

            foreach (T_PRT_CLIENTS dbclient in dbclients)
            {
                Client _client = new Client();
                _client.ClientId   = dbclient.CLIENT_ID;
                _client.ClientName = dbclient.CLIENT_NAME;
                //log.InsertT_PRT_SYS_LOG("info", dbclient.CLIENT_NAME);
                _client.AllowedGrantTypes = (dbclient.CLIENT_GRANT_TYPE == "HYBRID" ? GrantTypes.Hybrid : GrantTypes.Implicit);

                _client.RequireConsent = false;
                _client.AllowedScopes  = new List <string>
                {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile,
                    IdentityServerConstants.StandardScopes.Email,
                    "api.read"
                };
                _client.RedirectUris = new List <string> {
                    dbclient.CLIENT_REDIRECT_URI
                };
                //log.InsertT_PRT_SYS_LOG("info", dbclient.CLIENT_REDIRECT_URI);
                _client.PostLogoutRedirectUris = new List <string> {
                    dbclient.CLIENT_POST_LOGOUT_URI
                };
                //log.InsertT_PRT_SYS_LOG("info", dbclient.CLIENT_POST_LOGOUT_URI);
                _client.AllowAccessTokensViaBrowser = true;
                _client.AccessTokenLifetime         = 3600;
                if (_client.ClientId == "open_waters")
                {
                    _client.AllowedCorsOrigins = config["AllowedCorsOrigin4OW"].Split(",");
                }
                _clients.Add(_client);
            }

            return(_clients);
        }