# Finish the account management system.

Currently IG uses Drupal+d4os+my own custom module.  MG uses that jOpenSim thingy.  CG has manual account creation on ROBUST console.  CG and IG will move to what ever I put into OpenSim_SC.  CG needs something better soonish.



I first need to put a quick and dirty splash page into OpenSim_SC, so I get familiar with how the OpenSIm internal web server works.  Perhaps using server side includes to fill in "X users online" and such.



I eventually want to move to LDAP or something standard for accounts, but I can put that off, since I'll have to migrate away from the OpenSim account system anyway.  So what ever intermediate step/s can stay with the OpenSim account system.



Also eventually I'll want to use my Lua+WebAssembly+C/Lua web server modules thingy I have yet to invent ala matrix-RAD for web stuff.  So keep this in mind.



The problem is getting from here to there without too much extra work on in between steps.

---

reported=2019-08-03 06:32:45

reporter=onefang

priority=normal

category=Feature

severity=feature

resolution=open

---

2019-08-03 07:23:16 onefang: Hmm, what would work, and fit into my plans, would be a really basic, no frills, HTML forms based account management web page built into OpenSim_SC.

---

2019-08-04 00:25:42 onefang: opensim-SC/OpenSim/Framework/Console/RemoteConsole.cs is an example of authenticating a user.

---

2019-08-06 05:17:26 onefang: A simple CRUD system.  Using the new MySQLRaw.cs, don't bother making versions for other databases, this will likely only be used by a few grids that should stick to MariaDB / MySQL.  Confirmed that CG, IG, and MG all use MariaDB.



Have a table structure, filled with field structures.  A row structure will point to it, and include actual row data.  Also some top level databaseData structure that would include several rows, and be the thing that is edited.  The databaseData should include copies of the original data, so it can deal with the lost update problem.



---

2019-08-06 14:50:26 onefang: The list button should list all members, first and last names.  White for approved members, grey for disabled members, blue for gods.  If the logged in member is a god, they can click on a name to edit that member.  Just basic email, password, and approved / disabled / god status editing.



A logged in member can edit their own email and password.

---

2019-08-06 15:29:55 onefang: [s][url=https://www.codeproject.com/Articles/43438/Connect-C-to-MySQL]Looks useful.[/url]



[url=https://mariadb.com/kb/en/library/mariadb-and-net/]Looks scary.[/url]



[/s]



And they are both now irrelevant, I've switched to C + Lua, the C# .NET stuff is now legacy.



---

2019-08-07 07:01:40 onefang: Block creating accounts with the god first names, surnames, and full names, those can be done in the console.



---

2019-08-07 07:15:34 onefang: Replace first/last name with a single name field, then check if it's two words server side.  A great anti spammer thing I have found.

---

2019-08-07 20:48:14 onefang: [s]I should test the built in HTTPS support, but the problem is the cert, since I no longer have a public IP at home.



Use the [url=https://certbot.eff.org/docs/using.html#getting-certificates-and-choosing-plugins]manual DNS method of certbot[/url], and use one of the domains from afraid.  Or temporarily use sledjhamr, the webroot method as usual, then copy things.



[/s]



Now irrelevant, I've switched to C + Lua, the C# .NET stuff is now legacy.



---

2019-08-08 15:38:09 onefang: [s]LetsEncrypt gives you PEM files (private key file protected), and naturally MONO prefers the Microsoft PKCS12 files (password protected).  The following URLS should be useful -



https://stackoverflow.com/questions/7400500/how-to-get-private-key-from-pem-file



https://www.codeproject.com/Articles/162194/Certificates-to-DB-and-Back[/s]



Now irrelevant, I've switched to C + Lua, the C# .NET stuff is now legacy.



---

2019-08-09 10:29:40 onefang: [s]The HTTPS solution is to use openssl to convert from one format to the other.  I could spend a lot of time adding code to use PEM, but I can't be arsed, this is only temporary web server until I get around to writing the C + Lua version.[/s]



Now irrelevant, I've switched to C + Lua, the C# .NET stuff is now legacy.



---

2019-08-16 10:01:39 onefang: [s]HTTPS config is tricky.



config/config.ini is shared with sims, and they can't all use the same port.



config/ROBUST/RobustExtra.ini didn't work, not even if including it.  No idea why.  Figured out why, it has to be at the end.



[/s]



Now irrelevant, I've switched to C + Lua, the C# .NET stuff is now legacy.



---

2019-08-16 22:50:38 onefang: [b]Authentication and sessions.[/b]



Force SSL.



Two word name in a single edit box.  Password in a password box.



Create a token, pass it around.  Token expires, and is "only from IP xxx.xxx.xxx.xxx".  Token is in header, cookie, or both.  Both, and compare them to validate them.  The token should be non-predictable.  Hash the token like you would the password before storing it server side.  Regenerate the cookie when the user is authenticated.  Another possibility, split the token into two bits somehow, likely cryptographically, one in the header, the other in the cookie, then when recombined they must match something or other stored server side.



HttpOnly, Secure, Session, SameSite=Strict, Path=/web cookie.



Check the referer header is us.



Logout and password resets should invalidate the token.



Password reset and validation email could be the same process?  Re-use the hashed cookie stuff?



DoS protection against dictionary attacks - increasing delay type stuff, let the user know what's going on.



All sorts of other things, but I think this is enough for the simple account manager.



[url=https://stackoverflow.com/questions/549/the-definitive-guide-to-form-based-website-authentication?rq=1]Very useful.[/url]



[url=https://stackoverflow.com/questions/42824415/single-page-application-with-httponly-cookie-based-authentication-and-session-ma?noredirect=1&lq=1]Covers a specific detail about cookies.[/url]



[url=https://www.owasp.org/index.php/Session_fixation]Session fixation attack.[/url]



[url=https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies]Mozilla's docs on cookies.[/url]



---

2019-08-16 23:23:14 onefang: I should use prepared SQL statements.

---

2019-08-20 12:32:42 onefang: Add a validation field, and a "resend validation email" button.

---

2019-08-21 11:10:59 onefang: I've decided to not include the account manager stuff I have been working on in this release of OpenSim_SC (0.9.0.1).



I was using the built in OpenSim web server.  Something they wrote themselves, but that they didn't include the source code for it in the OpenSim source repo.  I managed to track down the source code, but dunno if it's the same version as the binary they include.  It's not designed for ordinary web pages, but rather as the internal communications between modules, and the viewer parts that run over HTTP.  It has support for HTTPS, but that's a rarely used option.  Turning it on so I can use it to protect account management resulted in lengthy error messages.  They happen when people are not using the account manager.



So I'm very worried that I am triggering not well tested code paths.  The current OpenSim_SC release candidate has been well tested, and I think it is ready for release soon, but not with HTTPS enabled causing new problems.



I planned to switch to lighttpd eventually anyway, even for the internal stuff.  I think I'll work on using that for account management after this release.  Lighttpd is about a third of the size of OpenSim web server, and heavily used by lots of people, being one of the top three open source web servers. Built to be light on resources and fast. It's a real web server, OpenSims isn't.



MG already has a Joomla based account system, IG has something similar based on Drupal, we will just have to wait a bit longer for my implementation.

---

2019-08-25 04:48:55 onefang: Add a MOTD when people log on, and allow to randomly pick it from a pool of MOTDs.



This feature requested by Taylor.

---

2019-08-28 12:42:41 Taylor: Feature request: Make partnering work via the accounts system.

---

2019-09-09 07:22:04 onefang: User must provide the old password when changing the password.  So that "someone used my existing session to change my password" wont work.

---

2019-09-09 07:22:41 onefang: Provide an option to use ssh keys or similar.

---

2019-09-30 14:31:51 onefang: [url=https://fidoalliance.org/fido-technotes-channel-binding-and-fido/]fido technotes channel binding and fido[/url] might be useful, though could be more or less what I came up with elsewhere, split token.

---

2019-10-01 12:08:39 onefang: [url=https://cwe.mitre.org/top25/archive/2019/2019_cwe_top25.html]2019 CWE Top 25 Most Dangerous Software Errors[/url] will be useful.

---

2019-10-05 04:23:17 onefang: Should get this web stuff to work on MOAP, and check if that works as a HUD.  Dynamic texture stuff likely wont work, I don't think text edit widgets are supported.



MOAP worked as a HUD, I was able to use Candy and chat in the IG chat room.



---

2019-10-20 04:58:19 onefang: I'd love to move on from the current OpenSim password hashing, to something more modern and more secure.  And then in a decades time update it once more.  The problem will be knowing which one to try, coz there will be old password hashes until old accounts can update.  I can store a "use password method X" number along with the account.



UPDATE - The problem here is that the hashing method might be cemented into place in the viewers.



Also should work out what the restrictions on passwords are, and display them at password create / change time.  Though things like password length limit is viewer dependent.



---

2019-10-30 12:07:43 onefang: I may have already taken care of this sort of attack, but double check it anyway -



[url=https://www.theregister.co.uk/2019/10/24/google_chrome_tightens_cookie_security/]cookie security[/url]

---

2020-01-23 14:46:16 onefang: WebAuthn is probably a good idea for 2FA and 3FA.



https://arstechnica.com/information-technology/2019/12/idevices-finally-get-key-based-protection-against-account-takeovers/



Also - https://www.theregister.co.uk/2020/02/04/security_key_google_opensk/  for DIY.



---

2020-01-23 23:34:57 Taylor: [quote=onefang]WebAuthn is probably a good idea for 2FA and 3FA.[/quote]



Does it support physical security keys?

---

2020-01-23 23:46:52 onefang: Yes, it's the new open standard for physical security keys and biometrics.  So finger prints, face scans, Yubikeys and such.  Apple was dragging their heels supporting it, now they do, so now all the big players support it, which is what the linked article is about.



3FA is three factors, the traditional "something you know, something you have, something you are", password, key, fingerprints respectively.  2FA is any two of those.

---

2020-05-02 11:14:48 onefang: The basic account creation, and admin approval stuff is done.  Enough to let people create accounts.  That's the very important show stopper bit, so I'll decrease the priority of this task now.

---

2020-07-04 15:51:27 onefang: https://www.theregister.com/2020/04/30/email_http_leakage/ Yet another privacy issue I'll have to keep an eye on for later.

---

2020-10-02 09:08:33 onefang: https://arstechnica.com/information-technology/2020/07/apple-has-finally-embraced-key-based-2fa-so-should-you/  Includes some more general info.

---

2020-12-15 22:18:45 onefang: For the validation link, they should have to log in before they can use it.  Helps avoid problems with email address typos that end up going to someone else, since someone else wont know the password.

---

2020-12-26 11:55:55 onefang: CRLF injection attacks is something I don't recall guarding against.



[url=https://en.wikipedia.org/wiki/HTTP_response_splitting]Wikipedia[/url]



[url=https://owasp.org/www-community/vulnerabilities/CRLF_Injection]OWASP[/url]



---

2021-03-02 08:54:03 onefang: "But it doesn't protect against injecting HTML. If the web application takes a field in the database and renders it on a page as HTML instead of text, you have an opportunity to get the page to run your own Javascript in what is known as an XSS attack. This is typically combined with spear phishing an administrator so you can exfiltrate their credentials when they load the page."



Double check I'm doing something about this.

---

2021-07-21 04:40:06 onefang: Send moar emailz!



Send one to admins when new member validates, or at least those that opt in.



Send one to new member when they are approved, with instructions on what to do next.

---

2021-07-25 10:40:27 onefang: https://fidoalliance.org/UX-guidelines/  More passwordless stuffs.
