Police will be able to reveal the identity of online stalkers under new right to know powers, the government has announced.