RestImageResize/Security/PrivateKeyQueryAuthorizer.cs
/// <summary>
/// Checks if image transformation query hash is valid (computed using a valid private key).
/// </summary>
/// <param name="query">Image transformation query.</param>
Checks if image transformation query hash is valid (computed using a valid private key).
Checks if image transformation query hash is valid ( computed using a valid private key ) .
public bool IsAuthorized(ImageTransformQuery query)
        {
            var privateKeys = _privateKeyProvider.GetAllPrivateKeys().ToList();
            if (!privateKeys.Any())
            {
                return true;
            }
            foreach (var privateKey in privateKeys)
            {
                var hash = _hashGenerator.ComputeHash(privateKey.Key, query.Width, query.Height, query.Transform);
                if (hash == query.Hash)
                {
                    return true;
                }
            }
            return false;
        }
public bool IsAuthorized ( ImageTransformQuery query ) { var privateKeys = _privateKeyProvider . GetAllPrivateKeys ( ) . ToList ( ) ; if ( ! privateKeys . Any ( ) ) { return true ; } foreach ( var privateKey in privateKeys ) { var hash = _hashGenerator . ComputeHash ( privateKey . Key , query . Width , query . Height , query . Transform ) ; if ( hash == query . Hash ) { return true ; } } return false ; }
Checks if image transformation query hash is valid (computed using a valid private key).
Checks if image transformation query hash is valid ( computed using a valid private key ) .
query
ImageTransformQuery
Image transformation query.
Image transformation query .