예제 #1
0
        /// <summary>
        /// Retrieves an authorization using its unique identifier.
        /// </summary>
        /// <param name="identifier">The unique identifier 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 identifier.
        /// </returns>
        public virtual async Task <OpenIddictAuthorization> FindByIdAsync(string identifier, CancellationToken cancellationToken)
        {
            var key = ConvertIdentifierFromString(identifier);

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

            var record = result.Items.FirstOrDefault();

            return(OpenIdModelFactory.CreateAuthorizationFromAWS(record));
        }
예제 #2
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));
        }