forgottenserver
forgottenserver copied to clipboard
Secure session tokens format (#4963)
This PR is based on https://github.com/otland/forgottenserver/pull/4958 , because without it, it was very hard to test build-in HTTP server.
TODO
- decide, if it's fine, that class
SessionTokenis ingame.cpp/game.h- should it be moved to separate filessessiontoken.cppandsessiontoken.h? - add migration that drops
sessionstable in database
Changes Proposed
Replace current TFS session tokens algorithm with new version that:
- does not use database
- detects when password to account changes
- has optional IP validation (default
false, inconfig.lua:sessionTokenIpVerification = false) - has configurable expiration time (default
30 days, inconfig.lua:sessionTokenExpirationTime = 30 * 24 * 3600) - uses SHA-256 sign to detect token modification with configurable secret sign key (default
""[empty string], inconfig.lua:sessionTokenSecretKey = "") - works with PHP acc. makers (MyAAC,
login.phpthat works with MyAAC: https://gist.github.com/gesior/6fb7e194a1aedb7980e98399bcca628d ) - I will make PR to MyAAC after this PR is merged into TFS