Commit Graph

57 Commits

Author SHA1 Message Date
Guangcong Luo
47a454cd16 Update paths for servers.inc.php 2020-07-27 16:44:21 -07:00
Annika
367ed82e56
Support configurable URLs (#1543) 2020-07-21 15:27:21 -07:00
Ben Davies
e3fcaa492c
Properly set the encoding to UTF-8 on all HTML pages (#1467)
This adds the BOM to all HTTP pages as per the HTML5 spec and ensures
all pages use UTF-8 as their meta charset (which is still kept for
compatibility with older browsers).
2020-02-23 00:13:56 -08:00
Guangcong Luo
189a987526 Allow CORS actions with a POSTed sid
This is mostly useful for the testclient, which otherwise can't interact
with the login server without huge hacks like the iframe copy/paste.

Requiring an external sid resolves any security issues; sid being the
only cookie we use for security-sensitive things, and also being our
CSRF token.

In theory, this is also useful for clients that don't support cookies,
although I'm unsure how they'd get their hands on an sid in the first
place. I guess just run login actions?
2019-02-27 05:16:17 -05:00
Guangcong Luo
82e7a917ab Move session library inside repository
For too long, ntbb-session and ntbb-database have been maintained
outside of this repo, but no longer! All these files are now part of the
repository, making it significantly more self-contained.

If I had to say why it took this long, I think it was mostly inertia. It
was easier leaving them where they were than having to audit them for
private keys in the wrong places, etc.

I'm starting to think of PS more as sim first, website secondary than
the other way around, now. Especially now that we don't have a forum,
the website itself isn't really important... Maybe one day I'll get rid
of the landing page and make the sim itself the first thing you see when
you hit pokemonshowdown.com... but today is not that day!

The repo is still not "batteries-included" since I am not going to teach
anyone how to set up PHP and MySQL or even get the config files working.
But for anyone who wanted their own client, well, it gets a lot easier
to do now.
2016-10-20 13:16:06 -04:00
Guangcong Luo
5e3a3377f0 Possible workarounds for Chrome CORS issue
A version of Chrome suddenly started complaining about PS's
cross-origin communication system. These changes seem to mostly
solve the issue.

This is kind of voodoo programming, but oh well. You do what you have
to to work around obscure client bugs.
2016-08-02 03:43:29 -04:00
Guangcong Luo
ccdd3fbf96 Fix minor error when Referer header not sent 2015-11-05 03:21:26 -05:00
Guangcong Luo
53a1c2ad9e Support HTTPS PS-to-desktop team dragging
Chrome is dumb and doesn't support data URLs in HTTPS, so we have
to round-trip through action.php
2015-07-14 15:03:47 -04:00
Cathy J. Fitzpatrick
82de98d166 Refactor action.php
This moves most of the logic of action.php into a separate file
lib/dispatcher.lib.php and separates the actions into ladder-related
actions and non-ladder-related actions. This is intended to make it
possible to have a second action.php that handlers only ladder-related
actions, which can run on the main server computer and allow
that computer to make HTTP requests to `localhost`, which should
help reduce ladder errors.
2013-04-01 23:21:33 -07:00
Cathy J. Fitzpatrick
f1f465abd3 Fix some errors in action.php 2013-04-01 17:03:19 -07:00
Cathy J. Fitzpatrick
2d9ffac01f Add regexp matching of origin to CORS support 2013-03-30 01:50:18 -07:00
Cathy J. Fitzpatrick
b2b286c6a9 Add option to skip the IP check in action.php
This fixes requests by servers behind certain kinds of proxies.
2013-03-29 17:49:46 -07:00
Cathy J. Fitzpatrick
6939054eb2 Fix logic error in IP identification 2013-03-22 18:52:07 -06:00
Cathy J. Fitzpatrick
ddf9ed4cea Implement opt-in identification of servers by IP 2013-03-22 18:45:21 -06:00
Cathy J. Fitzpatrick
d672ae57b5 Correctly synchronise sid and username across domains 2013-03-22 05:11:11 -06:00
Cathy J. Fitzpatrick
dc357d6f02 Allow empty serverid in action.php 2013-03-16 20:06:20 -06:00
Cathy J. Fitzpatrick
6d3b9d3af6 Fix to CORS support 2013-03-16 19:55:12 -06:00
Cathy J. Fitzpatrick
78ab39094c CORS support in action.php 2013-03-16 18:50:53 -06:00
Cathy J. Fitzpatrick
f91a508643 Better formatting of stats SQL query 2013-03-06 11:33:00 -07:00
Cathy J. Fitzpatrick
d135928404 Keep historical userstats in a separate table
This avoids making an expensive query on the site index.
2013-03-06 11:30:32 -07:00
Cathy J. Fitzpatrick
8b5199cdd1 Fix typo 2013-02-23 02:28:00 -07:00
Cathy J. Fitzpatrick
ba75dce604 Implement updateuserstats action 2013-02-23 02:25:34 -07:00
Cathy J. Fitzpatrick
4c2526b562 Revert recent changes for now
These changes introduced some unexpected issues.
2013-02-17 23:05:59 -07:00
Cathy J. Fitzpatrick
55581d5a48 Add server chooser to testclient.html 2013-02-17 22:35:04 -07:00
Cathy J. Fitzpatrick
34b309d58d Add serverlist action to action.php
The `serverlist` action returns a list of registered servers. It accepts
cross-domain requests, which is safe since it merely returns publicly
available information.
2013-02-17 21:53:02 -07:00
Cathy J. Fitzpatrick
37a6159bec Remove cached index.php logging feature
This feature isn't likely to obtain any further useful information.
2013-02-14 19:03:16 -07:00
Cathy J. Fitzpatrick
a022bd6ead Fix runtime error in login action when name or pass is empty 2013-02-11 02:35:00 -07:00
Cathy J. Fitzpatrick
2ff3957c3b Don't sign assertions for invalid usernames 2013-02-10 20:08:31 -07:00
Cathy J. Fitzpatrick
a6b7ad5977 Set maximum username length to 18 for consistency
The Pokemon Showdown server already enforced a maximum username length
of 18 characters, but the login server allowed registering names up to
63 characters long.
2013-02-10 19:18:21 -07:00
Cathy J. Fitzpatrick
5c1ec0b695 Allow two username registrations every two hours 2013-02-10 18:18:21 -07:00
Cathy J. Fitzpatrick
2ae1040c9f Revise formatting of action.php 2013-02-10 17:27:47 -07:00
Cathy J. Fitzpatrick
849786d782 Allow only one username registration per day 2013-02-10 17:19:51 -07:00
Cathy J. Fitzpatrick
23f9865992 Refactor serverid/servertoken 2013-02-09 04:50:49 -07:00
Cathy J. Fitzpatrick
78356e64c3 Specify character encoding for getassertion output 2013-02-09 02:40:42 -07:00
Cathy J. Fitzpatrick
d3c4bc26fe Remove two more unused actions 2013-02-08 19:24:13 -07:00
Cathy J. Fitzpatrick
3d810fa926 Remove more obsolete code from action.php 2013-02-08 18:37:40 -07:00
Cathy J. Fitzpatrick
500999151d Remove obsolete upkeep action from action.php 2013-02-08 18:15:21 -07:00
Cathy J. Fitzpatrick
86a81f9614 Display friendly error message when trying to register 'guest*' 2013-02-08 17:02:31 -07:00
Cathy J. Fitzpatrick
4076152c85 Add support for omitting userid for getassertion 2013-02-08 05:15:49 -07:00
Cathy J. Fitzpatrick
d2783cf610 No need to sanitise $challenge in getassertion
I now sanitise the challenge in getAssertion() instead.
2013-02-08 03:44:00 -07:00
Cathy J. Fitzpatrick
01522f0a15 Fix bug in testing for presence of challengekeyid 2013-02-08 01:07:52 -07:00
Cathy J. Fitzpatrick
f0fde921ec Changes to action.php for challenge-response authentication 2013-02-07 23:22:13 -07:00
Cathy J. Fitzpatrick
f7adbee232 More changes to cached index.php logging
- record lag time in the log
- use an <img> tag rather than an AJAX request to reduce false
  positives caused by slow internet
2013-02-07 13:54:24 -07:00
Cathy J. Fitzpatrick
7a50b31b6b More changes to cached index.php logging
- check timestamp in index.php rather than sim.js to reduce the chance
  of false positives caused by the user's internet connection being
  slow or the user's clock being slightly wrong

- require timestamp logging to be a POST request
2013-02-06 22:36:32 -07:00
Cathy J. Fitzpatrick
3e86a976dd Changes to cached index.php logging
- use human-readable times
- log user agent
2013-02-06 19:00:34 -07:00
Cathy J. Fitzpatrick
22138d3e25 Log cases where user has cached index.php
In addition, if the user has a cached index.php, we no longer make a
special request to action.php?act=upkeep.
2013-02-06 18:40:33 -07:00
Cathy J. Fitzpatrick
417d95c392 Server tokens are now optional for ladder updates
As of this commit, if a registered server does not provide us with
a server token, authentication for `ladderupdate` is based purely on
the IP address of the server. This technically also applies to
the `prepreplay` action, but only the main server can use that at
this time, so that does not actually change anything.
2013-02-06 16:34:43 -07:00
Cathy J. Fitzpatrick
83fe1d5b72 Don't return valid JavaScript from action.php
This avoids an attack where a malicious webpage contains

  <script id="data" type="application/json"
    src="http://play.pokemonshowdown.com/~~showdown/action.php?act=upkeep"/>

The webpage could then read the value of the `data` element using
standard DOM methods in order to steal the user's login assertion
and login as the user on the `showdown` server.
2013-02-04 20:42:38 -07:00
Cathy J. Fitzpatrick
2acc89748a Each server now gets its own session
This commit implements the following:

- each server now has a separate session with a 'sid' cookie
  scoped to /~~server:port

- 'sid' cookies are now HTTP-only and not accessible in JavaScript

- the showdown_token cookie is removed

Together, these changes fix various XSS attacks.
2013-02-02 19:37:57 -07:00
Cathy J. Fitzpatrick
5ae66a78aa Changes for Railgun 2013-01-31 22:33:00 -07:00