Skip to content

Add /openra/link route for ingame key registration.#57

Open
pchote wants to merge 1 commit intoOpenRA:masterfrom
pchote:login
Open

Add /openra/link route for ingame key registration.#57
pchote wants to merge 1 commit intoOpenRA:masterfrom
pchote:login

Conversation

@pchote
Copy link
Member

@pchote pchote commented Jan 31, 2026

/openra/link accept a POST request with username, password, and the public key generated by the game. This enables linking to be performed ingame, improving player experience.

It will return with one of:

Result Explanation
Success Public key was successfully added to the account
Error: invalid key Invalid key data was provided
Error: key exists Key is already registered to an account
Error: banned Forum account has been banned
Error: authentication failed Invalid username or password
Error: too many login attempts Too many incorrect auth attempts for the given user, or from the client's IP. These counters can be reset by waiting for the timeout (6h by default) or (re-)logging into the forum with a web browser and solving the captcha.

WHERE username_clean = '" . $this->db->sql_escape($username_clean) . "'";
if (!($result = $this->db->sql_query($sql)))
{
return $this->get_response("Error: authentication failed");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could reuse this string everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so, but I don't think there is a standard pattern for this elsewhere in phpBB to copy. I'm not convinced this would make things clearer.

$user_login_attempts = (is_array($row) && $this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']);
if ($ip_login_attempts || $user_login_attempts)
{
return $this->get_response("Error: too many login attempts");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to call this much earlier? WIth as few database accesses as possible? Also could whe do a query that would do both, increment login attempts and fetch it? It's different for every database, I dunno what resource center uses

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from the standard phpBB login flow. In principle we could change it, but without having a good handle in all the intricacies of php/phpBB I don't think that would be a good idea - the experts have probably done it like this for a reason.


if ($duplicates)
{
return $this->get_response("Error: key exists");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this mean? why do we want to fail here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't happen in the normal game flow (the game only calls this end point after it's confirmed that the key doesn't already exist) so is a sign that someone is trying to do something malicious.

return $this->get_response("Error: banned");
}

if (!$this->passwords_manager->check($password, $row['user_password'], $row))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is already hashed and salted password?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that is all handled internally by the password manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants