The tide seems to be turning against the U.S. National Security Agency's domestic surveillance programs, two years after Edward Snowden leaked controversial details on the agency's digital spying practices.

This week, ahead of various attempts in the U.S. Congress to either reauthorize, reform, or completely abolish the legal underpinnings of the NSA's digital surveillance programs, a federal appeals court dealt a big blow to the agency's domestic spying activities.

Appeals Court: Patriot Act 'Does Not Authorize' Metadata Collection

On Thursday, the Second Circuit Court of Appeals ruled that NSA's bulk metadata (phone records) collection program -- one of the less controversial aspects of the NSA's domestic surveillance initiatives -- is illegal under the current law.

Writing the decision on behalf of the three-judge panel, Judge Gerard Lynch stated the program "exceeds the scope of what Congress has authorized," according to its written decision for the case, ACLU vs. Clapper.

The Patriot Act -- the congressional authorization cited -- Lynch wrote, "cannot bear the weight the government asks us to assign it."

"It does not authorize the telephone metadata program," Lynch continued.

Congress Didn't Know What It Was Approving

The (erstwhile) secrecy of the NSA's metadata collection factored in to the court's decision. The Patriot Act was last reauthorized in 2011, but even members of Congress did not know much of the NSA's activities until Snowden's leak a year later.

Because of that, wrote Lynch, "Congress cannot reasonably be said to have ratified a program of which many members of Congress -- and all members of the public -- were not aware."

In fact, even lawmakers wrote the original Patriot Act say the law was never intended to be used for such extensive domestic surveillance.

Writing in his weekly column in 2013, Rep. Jim Sensebrenner -- the Patriot Act's original author -- highlighted the "large gap between the intention of the Patriot Act and the implementation of Section 215 by the FISA court and the Administration," demanding revisions "narrowing it's scope and enhancing judicial and congressional oversight."

Court Decision "Pulls the Rug Out" From Rubber Stampers

The House of Representatives is currently working to approve the USA Freedom Act, a bill that would end the metadata collection program and reform the secret FISA court to make sure warrants for data collection aren't a blank check for the secretive government spy agency.

But reform faces opposition from House and especially Senate leaders, like Senate Majority Leader Mitch McConnell, who would rather reauthorize the Patriot Act as-is than make large reforms to the NSA's authorization. The appeals court ruling, according to Sen. Chuck Schumer, "pulls the rug out from under Sen. McConnell" and the idea of rubber stamping the Patriot Act yet again.

No Constitutional Ruling: It's Up to Congress

But the appeals court left plenty of room for the warrantless domestic surveillance program to continue, and its decision emphasized the wide berth it was giving to questions of the law's ultimate constitutionality.

As Lynch wrote, "We reiterate that, just as we do not here address the constitutionality of the program as it currently exists, we do not purport to express any view on the constitutionality of any alternative version of the program. "

Despite finding that the Patriot Act, as currently written, doesn't authorize NSA spying, Lynch stated the court made that determination "comfortably in the full understanding that if Congress chooses to authorize such a far‐reaching and unprecedented program, it has every opportunity to do so, and to do so unambiguously."

Putting the ball back into Congress's court, Lynch wrote, "The constitutional issues, however, are sufficiently daunting to remind us of the primary role that should be played by our elected representatives in deciding, explicitly and after full debate, whether such programs are appropriate and necessary."

Congress has until June 1 -- the more practical deadline due to Congress's recess is Memorial Day, May 25 -- to decide whether the NSA's sweeping metadata collection program is either appropriate or necessary.