Merge pull request #81 from screepers/token-based-auth
Implement token-based auth
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
### Getting Started
|
### Getting Started
|
||||||
|
|
||||||
* [Installation](./getting-started/installation.md)
|
* [Installation](./getting-started/installation.md)
|
||||||
|
* [Authenticating with Screeps](./getting-started/authenticating.md)
|
||||||
* [Deploying](./getting-started/deploying.md)
|
* [Deploying](./getting-started/deploying.md)
|
||||||
|
|
||||||
### In-Depth
|
### In-Depth
|
||||||
|
|||||||
55
docs/getting-started/authenticating.md
Normal file
55
docs/getting-started/authenticating.md
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# Authenticating with Screeps
|
||||||
|
|
||||||
|
Screeps has recently introduced a [token-based auth system](http://blog.screeps.com/2017/12/auth-tokens/), and the old authentication system will be deprecated by 01 February 2018. The starter kit has been updated to support this new authentication process.
|
||||||
|
|
||||||
|
## Migrating to the new auth system
|
||||||
|
|
||||||
|
If you have an existing copy of your starter kit, follow these steps:
|
||||||
|
|
||||||
|
* Remove the `"username"` and `"password"` keys from your `screeps.json` file, and replace them with `"token"`.
|
||||||
|
* Upgrade `rollup-plugin-screeps` to version 0.1.1.
|
||||||
|
* Follow the authentication steps as defined below.
|
||||||
|
|
||||||
|
## Seting up Screeps authentication
|
||||||
|
|
||||||
|
The authentication token is pulled by the starter kit from a file named `screeps.json`. A sample config file (`screeps.sample.json`) is provided within the project, to use it, simply make a copy and rename it to `screeps.json`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp screeps.sample.json screeps.json
|
||||||
|
```
|
||||||
|
|
||||||
|
> **IMPORTANT:** The `screeps.json` file contains your Screeps credentials. If you use any source control, **DO NOT** check in this file into your repository.
|
||||||
|
|
||||||
|
## Generating an auth token
|
||||||
|
|
||||||
|
To generate an authentication token, click **[your username] > Manage account**. You should see the **Auth tokens** in the options now, click it.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
On the next screen, we'll create a full access token. We pick the **Full access** option, then click the **Generate Token** button.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Your generated token should now be shown on your screen. Copy it to your clipboard.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
> **Note:** This token will be displayed **only once**! Make sure to never lose it. However, if you did lose it, simply remove said token from your account, and create a new one.
|
||||||
|
|
||||||
|
Now, paste it to your `screeps.json` file.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Sanity check
|
||||||
|
|
||||||
|
Now we'll do a quick check if things are running properly. Let's perform a quick deploy.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run push-main
|
||||||
|
```
|
||||||
|
|
||||||
|
Now go to your Screeps client and check if the `main` branch is created, or if said branch already exists, the code is overwriten to it.
|
||||||
|
|
||||||
|
It works? Good, you've successfully authenticated!
|
||||||
|
|
||||||
|
Next up, we'll configure our environment and [run our first code deploy](./deploying.md).
|
||||||
@@ -2,17 +2,11 @@
|
|||||||
|
|
||||||
## Building your configuration file
|
## Building your configuration file
|
||||||
|
|
||||||
The starter kit builds your code using `rollup`, which uses a `screeps.json` file as its configuration file. A sample config file is provided within the project, to use it, simply make a copy and rename it to `screeps.json`.
|
The starter kit builds your code using `rollup`, which uses a `screeps.json` file we built on the previous section as its configuration file.
|
||||||
|
|
||||||
```bash
|
The `screeps.json` file is a JSON configuration file separated into multiple environments. We're going to focus on the `main` environment to get you started. If you'd like to deploy to a different branch, be sure to change the `branch` key to the branch you'd like to deploy to.
|
||||||
cp screeps.sample.json screeps.json
|
|
||||||
```
|
|
||||||
|
|
||||||
> **IMPORTANT:** The `screeps.json` file contains your Screeps credentials. If you use any source control, **DO NOT** check in this file into your repository.
|

|
||||||
|
|
||||||
The `screeps.json` file is a JSON configuration file separated into multiple environments. We're going to focus on the `main` environment to get you starter. Fill in your Screeps credentials accordingly, along with your target branch.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
> **Note:** You don't have to manually create the target branch in your Screeps client if it doesn't exist yet. `rollup-plugin-screeps` will do it for you.
|
> **Note:** You don't have to manually create the target branch in your Screeps client if it doesn't exist yet. `rollup-plugin-screeps` will do it for you.
|
||||||
|
|
||||||
|
|||||||
BIN
docs/getting-started/img/authenticating-1.png
Normal file
BIN
docs/getting-started/img/authenticating-1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
BIN
docs/getting-started/img/authenticating-2.png
Normal file
BIN
docs/getting-started/img/authenticating-2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
docs/getting-started/img/authenticating-3.png
Normal file
BIN
docs/getting-started/img/authenticating-3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
docs/getting-started/img/authenticating-4.png
Normal file
BIN
docs/getting-started/img/authenticating-4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -22,4 +22,4 @@ Or if you're running `yarn`:
|
|||||||
yarn
|
yarn
|
||||||
```
|
```
|
||||||
|
|
||||||
Next up, we'll configure our environment and [run our first code deploy](./deploying.md).
|
Once that's all done, let's [authenticate with the Screeps server](./authenticating.md).
|
||||||
|
|||||||
@@ -28,12 +28,12 @@
|
|||||||
"@types/lodash": "^3.10.1",
|
"@types/lodash": "^3.10.1",
|
||||||
"@types/screeps": "^2.1.0",
|
"@types/screeps": "^2.1.0",
|
||||||
"@types/source-map": "^0.5.2",
|
"@types/source-map": "^0.5.2",
|
||||||
"rollup": "^0.51.8",
|
"rollup": "^0.53.2",
|
||||||
"rollup-plugin-clean": "^1.0.0",
|
"rollup-plugin-clean": "^1.0.0",
|
||||||
"rollup-plugin-commonjs": "^8.2.6",
|
"rollup-plugin-commonjs": "^8.2.6",
|
||||||
"rollup-plugin-node-resolve": "^3.0.0",
|
"rollup-plugin-node-resolve": "^3.0.0",
|
||||||
"rollup-plugin-screeps": "0.0.1",
|
"rollup-plugin-screeps": "^0.1.1",
|
||||||
"rollup-plugin-typescript2": "^0.8.1",
|
"rollup-plugin-typescript2": "^0.9.0",
|
||||||
"tslint": "^5.8.0",
|
"tslint": "^5.8.0",
|
||||||
"typescript": "^2.6.1"
|
"typescript": "^2.6.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,11 +18,10 @@ export default {
|
|||||||
input: "src/main.ts",
|
input: "src/main.ts",
|
||||||
output: {
|
output: {
|
||||||
file: "dist/main.js",
|
file: "dist/main.js",
|
||||||
format: "cjs"
|
format: "cjs",
|
||||||
|
sourcemap: true
|
||||||
},
|
},
|
||||||
|
|
||||||
sourcemap: true,
|
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
clean(),
|
clean(),
|
||||||
resolve(),
|
resolve(),
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"main": {
|
"main": {
|
||||||
"email": "you@provider.tld",
|
"token": "YOUR_TOKEN",
|
||||||
"password": "Password",
|
|
||||||
"protocol": "https",
|
"protocol": "https",
|
||||||
"hostname": "screeps.com",
|
"hostname": "screeps.com",
|
||||||
"port": 443,
|
"port": 443,
|
||||||
@@ -9,8 +8,7 @@
|
|||||||
"branch": "main"
|
"branch": "main"
|
||||||
},
|
},
|
||||||
"sim": {
|
"sim": {
|
||||||
"email": "you@provider.tld",
|
"token": "YOUR_TOKEN",
|
||||||
"password": "Password",
|
|
||||||
"protocol": "https",
|
"protocol": "https",
|
||||||
"hostname": "screeps.com",
|
"hostname": "screeps.com",
|
||||||
"port": 443,
|
"port": 443,
|
||||||
|
|||||||
Reference in New Issue
Block a user