Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating readme with more detail #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 41 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,50 @@

# Installation

1. `npm install screepsmod-auth` in your server folder.
2. Thats it!
1. Either run `npm install screepsmod-auth` in your screeps private server folder or subscribe the Steam workshop https://steamcommunity.com/sharedfiles/filedetails/?id=800390576 if your using the in-game private server.
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be split into two subsections, npm version and steam version

Copy link
Author

Choose a reason for hiding this comment

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

Done


# Usage
2. Modify mods.json and add a new line in your mods list pointing to this mod like so:
Copy link
Member

Choose a reason for hiding this comment

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

Only applies to npm version

Copy link
Author

Choose a reason for hiding this comment

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

updated


## Steam Console method
1. Open the steam screeps client
2. In console, run `setPassword('YourDesiredPassword')`
3. Now you should be able to login via API
```
"mods": [
"node_modules\\screepsmod-auth\\index.js"
],
```
3. Relaunch your screeps private server.
3. Follow the
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate number

Copy link
Author

Choose a reason for hiding this comment

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

fixed

[CLI steps](#screeps-server-command-line-interface-cli-method) below to setup your username and password

# Setup

## Screeps Server Command Line Interface (CLI) method
1. Connect to your screeps private server once to create your account. You don't need to set an email as that won't be used. Just username and password is important.

2. Run the server's command line interface (CLI) either in Steam, or if your running a standalone server as described here https://github.com/screeps/screeps#command-line-interface-cli

3. In server's CLI, run

```
setPassword('yourUserName', 'yourPassword')
```
Note: that setPassword says to pass in the email. Don't do this. Instead give it your username.
Copy link
Member

Choose a reason for hiding this comment

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

If an email is set during step 1, it will accept either email or username

Copy link
Member

Choose a reason for hiding this comment

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

Just checked the code again, as I could have sworn I updated the README, trying setPassword without the correct params does actually say use username, and the code doesn't accept email for this one.

Copy link
Author

Choose a reason for hiding this comment

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

Alright, I'll leave it as it is as I think your saying my readme edits are correct right?


4. If you get back an error that setPassword isn't defined, then its likely your mod isn't installed. See the mod.json set above to fix it. If setPassword returns {} then that's also a failure as your user name wasn't found. If setPassword returns { modified: 1 }, then it succceded.

5. Now you should be able to login

## Web Form Method
1. Open the steam client at least once (Required to create initial account)
2. Goto http://yourServerHostOrIP:21025/authmod/password/
1. Connect to your screeps private server once to create your account. You don't need to set an email as that won't be used. Just username and password is important.

2. Send a POST call to http://yourServerHostOrIP:21025/authmod/password/ with this header:
Copy link
Member

Choose a reason for hiding this comment

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

This will not work, it requires a valid login token in order to set the password. The web form takes care of that by having the steam login button to obtain the token.

Copy link
Author

Choose a reason for hiding this comment

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

So does the web form method only support steam then? I'm using the npm method and I had to use fiddler, edit the POST call according and reply it, and it returned 200. Not sure if it actually worked however

Copy link
Member

Choose a reason for hiding this comment

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

It support both steam and npm, it uses the steam oauth system to get a valid steam auth, which the server then returns a server auth token to the form. It uses that token for authentication to set the password. it needs to authenticate the user first in order to prevent just anyone from setting the password. Since it uses the steam login system, it also auto-creates the user if it doesn't exist. However, I have been seeing it take two tries to set the password. I haven't had the time to poke at that and figure out the cause yet.

```
Content-Type: application/json
```
and the body of

```
{ "email":"yourUserName", "password": "yourPassword" }
```

3. Enter your desired password
4. Click Signin with steam
5. Your password should be set and you be able to login via API
Expand Down Expand Up @@ -54,4 +85,4 @@ or manual approval to control spawning.
[auth]
cpu = 100
preventSpawning = false
```
```