During the events of Star Trek: First Contact we see Worf, Picard, and Crusher give authorization codes for the self-destruct of the Enterprise-E. I can understand why Picard and Crusher would have them, being senior officers, but why Worf? He was stationed on DS9 and was commanding the Defiant at the beginning of the movie.
In First Contact (1996), many of the senior staff of Enterprise, working planetside, were unable to return to the ship during the shipboard emergency. Picard needed trusted senior officers, and Worf had nothing else to do at the time, so Picard may have given him temporary command access.
Kirk faced a similar situation in The Wrath of Khan (1982). Enterprise had an inexperienced student crew, and Kirk asked the recently-rescued Chekov (from the USS Reliant) to man Enterprise's weapons console for the final battle with Khan.
This captain's prerogative has precedent1 in Star Trek: Discovery ("Lethe", 2017). Captain Lorca reminded Admiral Cornwell that Starfleet regulations allowed him to requisition practically anyone or anything to deal with his ship's role in the series' crisis.
1 Retroactively-applied precedent, considering the filming order, but it shows how Starfleet operates.
My working theory is that the Enterprise requires an officer with command code authority ( ex: Captain, or person in command of the ship, like the first officer when the captain is off ship/incapacitated) as well as the confirmation of 2 senior command level officers (a commander or lieutenant commander)
Each and every officer appears to have their own personal set of codes. Multiple codes with different levels of authority based on their rank, position, and function on the ship and in star fleet. These codes authenticate the officer themselves. The officer would then be authorized for different things, both specific (example: access to their own personal files/quarters) or generic (Such as rank based authority, or "level 9 security access")
In a crisis, the top senior officers may become incapacitated or killed, so the ability to maintain an authentication chain needs to be flexible enough to get around this.
Given Worfs rank of Lieutenant Commander, his command of the defiant (prior to being picked up), and his high level position on DS9, it makes sense that the computer would accept his authority to confirm the captains self-destruct order.
If Worf had attempted to initiate the self-destruct command himself, especially with Picard still on board and in command, it is likely the computer would not have permitted him.
In the episode Gambit, Riker uses his access/command codes to deaactivate the Enterprise's shields. In the dialogue leading up to this, it is revealed that the codes would have been changed as soon as he was taken prisoner. This indicates that it is either standard procedure to change or lock out the personal command codes of various officers when they embark, disembark, get captured etc or that it is automatically done by the computer.
Worf was, for all intents and purposes, temporarily assigned to the Enterprise E during the events of First Contact. It seems likely that his command codes were activated either by the computer or one of the senior staff when he came on board.