示例#1
0
        /// <summary>
        /// Retrieves an application using its client identifier.
        /// </summary>
        /// <param name="identifier">The client identifier associated with the application.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
        /// <returns>
        /// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
        /// whose result returns the client application corresponding to the identifier.
        /// </returns>
        public virtual async Task <OpenIddictApplication> FindByClientIdAsync(string identifier, CancellationToken cancellationToken)
        {
            var result = await _dynamoDb.QueryAsync(new QueryRequest
            {
                TableName = "OpenIdApplication",
                KeyConditionExpression    = "ClientId = :v_ClientId",
                ExpressionAttributeValues = new Dictionary <string, AttributeValue> {
                    { ":v_ClientId", new AttributeValue {
                          S = identifier
                      } }
                }
            }, cancellationToken);

            var record = result.Items.FirstOrDefault();

            return(OpenIdModelFactory.CreateApplicationFromAWS(record));
        }
示例#2
0
        /// <summary>
        /// Retrieves an token using its unique identifier.
        /// </summary>
        /// <param name="identifier">The unique identifier associated with the token.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
        /// <returns>
        /// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
        /// whose result returns the token corresponding to the unique identifier.
        /// </returns>
        public virtual async Task <OpenIddictToken> FindByIdAsync(string identifier, CancellationToken cancellationToken)
        {
            var key = ConvertIdentifierFromString(identifier);

            var result = await _dynamoDb.QueryAsync(new QueryRequest
            {
                TableName = TableName,
                KeyConditionExpression    = "Id = :v_Id",
                ExpressionAttributeValues = new Dictionary <string, AttributeValue> {
                    { ":v_Id", new AttributeValue {
                          S = key
                      } }
                },
            }, cancellationToken);

            var record = result.Items.FirstOrDefault();

            return(record != null?OpenIdModelFactory.CreateTokenFromAWS(record) : null);
        }
示例#3
0
        /// <summary>
        /// Retrieves an authorization using its associated subject/client.
        /// </summary>
        /// <param name="subject">The subject associated with the authorization.</param>
        /// <param name="client">The client associated with the authorization.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
        /// <returns>
        /// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
        /// whose result returns the authorization corresponding to the subject/client.
        /// </returns>
        public virtual async Task <OpenIddictAuthorization> FindAsync(string subject, string client, CancellationToken cancellationToken)
        {
            var key = ConvertIdentifierFromString(client);

            var result = await _dynamoDb.QueryAsync(new QueryRequest
            {
                TableName = DBName,
                KeyConditionExpression    = "ApplicationId = :v_ApplicationId",
                FilterExpression          = "Subject = :v_Subject",
                ExpressionAttributeValues = new Dictionary <string, AttributeValue> {
                    { ":v_ApplicationId", new AttributeValue {
                          S = key
                      } },
                    { ":v_Subject", new AttributeValue {
                          S = subject
                      } }
                }
            }, cancellationToken);

            var record = result.Items.FirstOrDefault();

            return(OpenIdModelFactory.CreateAuthorizationFromAWS(record));
        }