示例#1
0
        public NpgsqlClientStore(NpgsqlConnection conn, NpgsqlSchema schema)
        {
            Preconditions.IsNotNull(conn, nameof(conn));
            Preconditions.IsShortString(schema, nameof(schema));

            _conn       = conn;
            _schema     = schema;
            _serializer = JsonSerializerFactory.Create();

            _findQuery = "SELECT client_id, model " +
                         $"FROM {_schema}.clients " +
                         "WHERE client_id = @client";
            _insertQuery = $"INSERT INTO {_schema}.clients(client_id, model) " +
                           "VALUES(@client, @model);";
        }
示例#2
0
        public NpgsqlScopeStore(NpgsqlConnection conn, NpgsqlSchema schema)
        {
            Preconditions.IsNotNull(conn, nameof(conn));
            Preconditions.IsShortString(schema, nameof(schema));

            _serializer = JsonSerializerFactory.Create();

            _conn   = conn;
            _schema = schema;

            _findQuery = "SELECT name, is_public, model " +
                         $"FROM {_schema}.scopes " +
                         "WHERE name = any (@names)";

            _getQuery = "SELECT name, is_public, model " +
                        $"FROM {_schema}.scopes " +
                        "WHERE is_public = @public";
        }
示例#3
0
        protected BaseNpgsqlTokenStore(NpgsqlConnection conn, NpgsqlSchema schema,
                                       TokenType storedTokenType, IScopeStore scopeStore, IClientStore clientStore)
        {
            StoredTokenType = storedTokenType;

            Conn   = conn;
            Schema = schema;

            _serializer = JsonSerializerFactory.Create();
            _serializer.Converters.Add(new ClaimsPrincipalConverter());
            _serializer.Converters.Add(new ClientConverter(clientStore));
            _serializer.Converters.Add(new ScopeConverter(scopeStore));

            _scopeStore  = scopeStore;
            _clientStore = clientStore;


            // Queries
            _revokeQuery = $"DELETE FROM {Schema}.tokens " +
                           "WHERE subject = @subject " +
                           " AND client = @client " +
                           " AND token_type = @tokenType";
            _removeQuery = $"DELETE FROM {Schema}.tokens " +
                           "WHERE key = @key " +
                           " AND token_type = @tokenType";

            _getQuery = $"SELECT * FROM {Schema}.tokens " +
                        "WHERE key = @key " +
                        " AND token_type = @tokenType";

            _getAllQuery = $"SELECT * FROM {Schema}.tokens " +
                           "WHERE subject = @subject " +
                           " AND token_type = @tokenType";

            _insertQuery = "INSERT INTO " +
                           $"{Schema}.tokens(key, token_type, subject, client, expiry, model) " +
                           "VALUES(@key, @token_type, @subject, @client, @expiry, @model); ";
        }