Cars approach the front gate to the Coleman Federal Correctional Complex in Coleman, Florida, Sept. 6, 2011. REUTERS

Female workers who alleged they were sexually harassed by prisoners at a federal correctional facility have reached a settlement with the Bureau of Prisons that could be worth up to $20 million. The suit was filed in 2013 by 524 former and current female guards, teachers, nurses and office workers at Coleman Federal Correctional Complex outside of Orlando.

The workers said prison administrators failed to punish male inmates who repeatedly groped workers, masturbated in front of them, and threatened them with sexual violence, WFLA in Florida reported. "Throughout my shift, inmates were masturbating everywhere. It felt like a free for all,” one woman said, according to court documents reviewed by Quartz. “I probably saw 25 to 30 inmates masturbating during this one shift.”

A judge signed off Friday on the $20 million settlement, one of the largest payouts for class action sexual harassment lawsuits in history. The settlement also forces Coleman Federal Correctional Complex to put in place a variety of protections for female staff. These include staff harassment training, inmate psychological screenings and treatment, and pocketless inmate uniforms that prevent inmates from masturbating in front of workers. Prison staff will also be required to identify the inmates who are harassing female workers and punish them by losing privileges, the Associated Press said.

Attorney Heidi Burakiewicz, who represented the workers, told Quartz that at Coleman inmates would regularly negotiate with prison workers to be placed near specific female workers. The lawsuit claims that one women alleged that a supervisor responded to her complaints by replying, "If I was an inmate I would do the same thing."

Coleman houses 1,257 total inmates, according to the Bureau of Prisons website.

The first class-action sexual harassment lawsuit was Jenson vs. Eveleth Mines, which was settled in 1998 when 15 female mine workers won an undisclosed amount after nearly a decade of legal wrangling.