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

Login/Password issues TiddlyServer v2.2.0-beta-2 #107

Open
primetimber opened this issue Dec 30, 2020 · 3 comments
Open

Login/Password issues TiddlyServer v2.2.0-beta-2 #107

primetimber opened this issue Dec 30, 2020 · 3 comments

Comments

@primetimber
Copy link

I am having trouble getting into the tiddlywiki. I followed "Getting Started". Everything looks good, but I am having trouble finding out, where to set login and password. settings.json looks like this:

{
	"tree": "./wikidata",
	"bindInfo": {
	"bindWildcard": true
	},

	"authAccounts": {},

	"putsaver": {
	"backupFolder": "./backups"
	},

	"$schema": "./tiddlyserver-2-2.schema.json"
}
@Arlen22
Copy link
Owner

Arlen22 commented Dec 30, 2020

Go to /admin/authenticate/login.html and type in your desired username and password. This will print a message to the server console containing the public key and username.

    login attempted with unknown public key
    <base64 encoded string>
    username: test
    timestamp: 2020-12-30T19:59:16.580Z

Run the command node -e "console.log(Date.now())" to get the current timestamp for the cookie suffix. This just makes sure you don't accidentally re-use the same suffix for the same user. The suffix is used to force a user to be logged out of all sessions.

Now add a new key to the authAccounts object.

  "authAccounts": {
    "group name": { // << this is the "group" name such as "admin" or whatever you want
      "clientKeys": {
        "test": { // << this is the username you typed into the login form
          "cookieSalt": "timestamp from command",
          "publicKey": "<base64 encoded string>"
        }
      },
      "permissions": {
        "loginlink": true,
        "mkdir": true,
        "putsaver": true,
        "registerNotice": true,
        "upload": true,
        "websockets": true,
        "writeErrors": true,
        "transfer": true,
        "datafolder": true
      }
    }
  },

After this, modify your tree option to look like this

"tree": {
  "$element": "group",
  "$options": [
    // the auth list array specifies which authAccounts groups are allowed to access this resource. 
    { "$element": "auth", "authList": ["group name"]}, 
  ],
  "$children": // << your original tree value goes here
}

And then login again.

Sorry it looks so messy. The tree is so much nicer in XML.

<!-- the authList property is a JSON array -->
<tree>
  <!-- this protects the entire tree -->
  <auth authList='["group name"]' />  
  <folder path="/user/hello">
    <!-- Allows an additional group. Both groups must be included here. -->
    <auth authList='["group name", "other group]' /> 
  </folder>
  <group>
    <!-- obviously unnecessary, only here for demonstration -->
    <auth authList='["group name"]' /> 
    <folder path="/user/hello">
      <!-- this allows anyone to access this resource -->
      <auth authList='null' />
    </folder>
  </group>
</tree>

And then you just set the path to the XML as your tree option.

@Arlen22
Copy link
Owner

Arlen22 commented Dec 30, 2020

I was looking over this code and I just realized instead of a JSON attribute, you can also do this.

<auth>
  <authList>group name</authList>
  <authList>other group</authlist>
</auth> 

@primetimber
Copy link
Author

thank you. now I have a better understanding.
I found my other mistake. I forgot, that there is a difference between installing the tiddlywiki itself and the tiddlyserver m(
One of the pull requests (#84) describes it in a way.

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

No branches or pull requests

2 participants