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

auth failed #1129

Closed
1mfaasj opened this issue Sep 9, 2021 · 3 comments
Closed

auth failed #1129

1mfaasj opened this issue Sep 9, 2021 · 3 comments

Comments

@1mfaasj
Copy link

1mfaasj commented Sep 9, 2021

I run remark in docker and followed all instructions, including the google , twitter and github authentication, but after successfully logging in in these ways I can't get any further.
it doesn't indicate that I'm logged in, so I can't comment on the page where I want to load it, either.

the error is:
2021/09/09 09:17:59.609 [DEBUG] {middleware/auth.go:71 middleware.(*Authenticator).auth.func1} auth failed, can't get token: token cookie was not presented: http: named cookie not present
I use remark in combination with hugo

my docker compose looks like. ofcourse the real values are removed , so I replaced it with "key"

version: "3"
services:
  remark:
    image: umputun/remark42:latest
    networks:
      - traefik_public
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"
    environment:
      - REMARK_URL=https://remark.mydomain.com
      - SECRET=dhh30iJSKAJskqj2ejpdlsdsdtt
      - SITE=remark
      - STORE_BOLT_PATH=/srv/var/db
      - BACKUP_PATH=/srv/var/backup
      - DEBUG=true
      - AUTH_GITHUB_CID=key
      - AUTH_GITHUB_CSEC=key
      - AUTH_TWITTER_CID=key
      - AUTH_TWITTER_CSEC=key
      - AUTH_GOOGLE_CID=key
      - AUTH_GOOGLE_CSEC=key
    volumes:
      - /myvolume/remark:/srv/var
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.remark-rtr.entrypoints=https"
        - "traefik.http.routers.remark-rtr.rule=Host(`remark.mydomain.com`)"
        - "traefik.http.routers.remark-rtr.middlewares=chain-no-auth@file"
        - "traefik.http.routers.remark-rtr.service=remark-svc"
        - "traefik.http.services.remark-svc.loadbalancer.server.port=8080"

networks:
  traefik_public:
    external: true

when I go to https://remark.mydomain.com/api/v1/user?site=remark
it gives me Unauthorized...

strange because I've set the environment variable as remark..

this is how the comments page looks like in Hugo

<div id="remark42"></div>

<script>
  var remark_config = {
    host: "https://remark.mydomain.com", // hostname of Remark42 server, same as REMARK_URL in backend config, e.g. "https://demo.remark42.com"
    site_id: 'remark',
    components: ['embed'], // optional param; which components to load. default to ["embed"]
                           // to load all components define components as ['embed', 'last-comments', 'counter']
                           // available component are:
                           //   - 'embed': basic comments widget
                           //   - 'last-comments': last comments widget, see `Last Comments` section below
                           //   - 'counter': counter widget, see `Counter` section below
    url: 'PAGE_URL', // optional param; if it isn't defined
                     // `window.location.origin + window.location.pathname` will be used
                     //
                     // Note that if you use query parameters as significant part of URL
                     // (the one that actually changes content on page)
                     // you will have to configure URL manually to keep query params, as
                     // `window.location.origin + window.location.pathname` doesn't contain query params and
                     // hash. For example, default URL for `https://example/com/example-post?id=1#hash`
                     // would be `https://example/com/example-post`
                     //
                     // The problem with query params is that they often contain useless params added by
                     // various trackers (utm params) and doesn't have defined order, so Remark42 treats differently
                     // all this examples:
                     // https://example.com/?postid=1&date=2007-02-11
                     // https://example.com/?date=2007-02-11&postid=1
                     // https://example.com/?date=2007-02-11&postid=1&utm_source=google
                     //
                     // If you deal with query parameters make sure you pass only significant part of it
                     // in well defined order
    max_shown_comments: 10, // optional param; if it isn't defined default value (15) will be used
    theme: 'dark', // optional param; if it isn't defined default value ('light') will be used
    page_title: 'Moving to Remark42', // optional param; if it isn't defined `document.title` will be used
    locale: 'en', // set up locale and language, if it isn't defined default value ('en') will be used
    show_email_subscription: false, // optional param; by default it is `true` and you can see email subscription feature
                                    // in interface when enable it from backend side
                                    // if you set this param in `false` you will get notifications email notifications as admin
                                    // but your users won't have interface for subscription
    simple_view: false // optional param; overrides the parameter from the backend
                       // minimized UI with basic info only
  };
</script>
<script>!function(e,n){for(var o=0;o<e.length;o++){var r=n.createElement("script"),c=".js",d=n.head||n.body;"noModule"in r?(r.type="module",c=".mjs"):r.async=!0,r.defer=!0,r.src=remark_config.host+"/web/"+e[o]+c,d.appendChild(r)}}(remark_config.components||["embed"],document);</script>

@paskal
Copy link
Sponsor Collaborator

paskal commented Sep 9, 2021

Could you please try using umputun/remark42:master instead?

@1mfaasj
Copy link
Author

1mfaasj commented Sep 10, 2021

Okay it works. I had remark on a different domain than the website I wanted to activate it on.
probably to do with cors

thanks!

@1mfaasj 1mfaasj closed this as completed Sep 10, 2021
@gradosevic
Copy link

I have the same issue when using a site on a different domain:

 [DEBUG] {middleware/auth.go:71 middleware.(*Authenticator).auth.func1} auth failed, can't get token: token cookie was not presented: http: named cookie not present

In the browser, I get 401 and Unauthorize after logging in.

I want to use one docker instance on remark.example1.com for all of my sites, including other domains. I presume this is supported? I have enabled CORS in my example1.com site (please check the virtual host config down below).

Basically, I have added both sites example1.com and example2.com in yml and disabled docker cors with PROXY_CORS=true, but it's not working. If I switch to use the exact site either example1 or example2 it works but when I try to access e.g. site example2.com on remark.example1.com it doesn't work.

This is my yml file

version: "2"

services:
  remark:
    build: .
    image: umputun/remark42:latest
    container_name: "remark42"
    hostname: "remark42"
    restart: always

    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"

    # uncomment to expose directly (no proxy)
    ports:
      - "8888:8080"

    environment:
      - REMARK_URL=https://remark.example1.com
      - SECRET=secret
      - SITE=example1.com,example2.com
      - STORE_BOLT_PATH=/srv/var/db
      - BACKUP_PATH=/srv/var/backup
      - PROXY_CORS=true
      - DEBUG=true
      - AUTH_ANON=true
      - AUTH_GOOGLE_CID=<key>
      - AUTH_GOOGLE_CSEC=<key>
      - NOTIFY_ADMINS=slack
      - NOTIFY_SLACK_CHAN=<channel>
      - NOTIFY_SLACK_TOKEN=<key>
      - AUTH_GITHUB_CID=<key>
      - AUTH_GITHUB_CSEC=<key>
    volumes:
      - ./var:/srv/var

My Apache virtual host for remark.example1.com looks something like this:

<VirtualHost *:443>
        Header set Access-Control-Allow-Origin "*"
        ServerName remark.example1.com
        ServerAlias www.remark.example1.com

	ProxyRequests Off
	ProxyPreserveHost On
	ProxyVia Full
	<Proxy *>
		Require all granted
	</Proxy>

	RequestHeader set X-Forwarded-Proto "https"
	RequestHeader set X-Forwarded-Port "443"
	
        ProxyPass /  http://127.0.0.1:8888/
	ProxyPassReverse / http://127.0.0.1:8888/
...

Thanks for help.

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

3 participants