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

You are not a server admin error #229

Open
dsebastien opened this issue Aug 5, 2020 · 4 comments
Open

You are not a server admin error #229

dsebastien opened this issue Aug 5, 2020 · 4 comments

Comments

@dsebastien
Copy link

Expected Behavior

Stable connection to CouchDB

Current Behavior

Sometimes, I receive the "You are not a server admin" error when performing requests using my back-end server. I suppose that it is due to the way that I create the DB connection.

I'm currently using the following code:

export const databaseConnection: ServerScope = nano({
  url: environment.databaseConfiguration.url,
  requestDefaults: {
    // enable cookie-based authentication
    // Reference: https://www.npmjs.com/package/nano#using-cookie-authentication
    jar: true,
    auth: {
      username: environment.databaseConfiguration.username,
      password: environment.databaseConfiguration.password,
    },
  },

Later, in my repository code, I simply use that constant to make database calls:

public ensureThatWorkspaceExists(workspaceId: string): Observable<boolean> {
    return from(this.databaseConnection.db.list()).pipe(
      switchMap((databasesList) => {
        const databaseExists = databasesList.filter((existingDatabase) => {
          return existingDatabase === workspaceId;
        });

        if (databaseExists.length === 0) {
          throw new GateTechnicalError(GateTechnicalErrorType.DATABASE_NOT_FOUND);
        }
        return of(true);
      }),
    );
  }

Context

I've tried to configure cookie authentication in order to streamline things, but I suppose that I'm not using it correctly?
What surprises me is that it seems to work, most of the time, except that:

  • it seems to fail if my API server is started before CouchDB
  • it seems to fail after a while (when the cookie expires??)

When it fails, I get the "You are not a server admin" response when I try to make calls. Restarting the back-end server (not Couch) fixes the issue temporarily.

What would you recommend to avoid having such issues?

Your Environment

  • Version used: 8.2.2
  • Browser Name and version: N/A
  • Operating System and version (desktop or mobile): Linux (Ubuntu 20.20)
  • Link to your project: N/A
@janl
Copy link
Member

janl commented Oct 28, 2020

is this by chance against a cluster (and not a single node)?

@dsebastien
Copy link
Author

No, it is a single node.
For the moment, I've disabled cookie authentication as the issue continued to occur from time to time.

@janl
Copy link
Member

janl commented Nov 10, 2020

is this maybe related to your configured cookie session time?

@dsebastien
Copy link
Author

dsebastien commented Jan 14, 2021

I think so, yes. I actually disabled the following setting: "allow_persistent_cookies". I guess I wanted to be overprotective, by avoiding "forever" cookies, and instead created a situation where I have "never" cookies? ;-)

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