-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Self hosted: Google login redirects to app.affine.com? #6886
Comments
Please provide the config output when the selfhost server starts, let us check whether your config is correct。 |
I will attach the startup logs from docker-compose, and my configs: Docker Compose logsaffine_selfhosted | running predeploy script.
affine_selfhosted | yarn run v1.22.19
affine_selfhosted | $ yarn prisma migrate deploy && node --import ./scripts/register.js ./dist/data/index.js run
affine_selfhosted | $ /app/node_modules/.bin/prisma migrate deploy
affine_selfhosted | Prisma schema loaded from schema.prisma
affine_selfhosted | Datasource "db": PostgreSQL database "affine", schema "public" at "postgres:5432"
affine_selfhosted |
affine_selfhosted | 30 migrations found in prisma/migrations
affine_selfhosted |
affine_selfhosted |
affine_selfhosted | No pending migrations to apply.
affine_selfhosted | (node:150) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
affine_selfhosted | (Use `node --trace-warnings ...` to show where the warning was created)
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [NestFactory] Starting Nest application...
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] CommandRootModule dependencies initialized +23ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] AppModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] PrismaModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] WebSocketModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] SyncModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] ServerConfigModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] GqlModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] CacheModule dependencies initialized +6ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] DiscoveryModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] DiscoveryModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] EventModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] MutexModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] MetricsModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] MailerModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] StorageProviderModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] HelpersModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] ServeStaticModule dependencies initialized +1ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] EventEmitterModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] ScheduleModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] CommandRunnerModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] FeatureModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] StorageModule dependencies initialized +1ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] MailModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] ThrottlerModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] CliAppModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] GraphQLSchemaBuilderModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] RateLimiterModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] QuotaModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] DocModule dependencies initialized +1ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] OAuthModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] EventsModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] UserModule dependencies initialized +1ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] AuthModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] GraphQLModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [InstanceLoader] WorkspaceModule dependencies initialized +0ms
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [OAuthProvider:google] OAuth provider registered.
affine_selfhosted | [Nest] 150 - 05/12/2024, 10:16:52 AM LOG [RunCommand] Done 0 migrations
affine_selfhosted | Done in 4.18s.
affine_selfhosted | (node:229) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
affine_selfhosted | (Use `node --trace-warnings ...` to show where the warning was created)
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [NestFactory] Starting Nest application...
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] AppModule dependencies initialized +26ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] PrismaModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] WebSocketModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] SyncModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] ServerConfigModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] GqlModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] CacheModule dependencies initialized +5ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] DiscoveryModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] MetricsModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] MailerModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] StorageProviderModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] HelpersModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] EventModule dependencies initialized +1ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] MutexModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] ServeStaticModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] EventEmitterModule dependencies initialized +1ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] ScheduleModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] MailModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] FeatureModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] StorageModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] ThrottlerModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] RateLimiterModule dependencies initialized +1ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] QuotaModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] GraphQLSchemaBuilderModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] DocModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] OAuthModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] EventsModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] UserModule dependencies initialized +1ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] AuthModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] GraphQLModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [InstanceLoader] WorkspaceModule dependencies initialized +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [WebSocketsController] EventsGateway subscribed to the "client-handshake-sync" message +8ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [WebSocketsController] EventsGateway subscribed to the "client-handshake-awareness" message +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [WebSocketsController] EventsGateway subscribed to the "client-leave-sync" message +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [WebSocketsController] EventsGateway subscribed to the "client-leave-awareness" message +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [WebSocketsController] EventsGateway subscribed to the "client-pre-sync" message +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [WebSocketsController] EventsGateway subscribed to the "client-update-v2" message +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [WebSocketsController] EventsGateway subscribed to the "doc-load-v2" message +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [WebSocketsController] EventsGateway subscribed to the "awareness-init" message +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [WebSocketsController] EventsGateway subscribed to the "awareness-update" message +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RoutesResolver] AuthController {/api/auth}: +1ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/auth/sign-in, POST} route +1ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/auth/sign-out, GET} route +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/auth/magic-link, POST} route +1ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/auth/session, GET} route +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/auth/sessions, GET} route +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/auth/challenge, GET} route +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RoutesResolver] UserAvatarController {/api/avatars}: +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/avatars/:id, GET} route +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RoutesResolver] WorkspacesController {/api/workspaces}: +1ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/workspaces/:id/blobs/:name, GET} route +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/workspaces/:id/docs/:guid, GET} route +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/api/workspaces/:id/docs/:guid/histories/:timestamp, GET} route +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RoutesResolver] OAuthController {/oauth}: +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/oauth/login, GET} route +1ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [RouterExplorer] Mapped {/oauth/callback, GET} route +0ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [DocManager] Use Database
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [DocManager] Automation started
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [GraphQLModule] Mapped {/graphql, POST} route +83ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [OAuthProvider:google] OAuth provider registered.
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [NestApplication] Nest application successfully started +15ms
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [App] AFFiNE Server is running in [selfhosted] mode
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [App] Listening on http://0.0.0.0:3010
affine_selfhosted | [Nest] 229 - 05/12/2024, 10:16:54 AM LOG [App] And the public server should be recognized as https://my.custom.domain affine.js config//
// ###############################################################
// ## AFFiNE Configuration System ##
// ###############################################################
// > Configurations merge order
// 1. load environment variables (`.env` if provided, and from system)
// 2. load `src/fundamentals/config/default.ts` for all default settings
// 3. apply `./affine.ts` patches (this file)
// 4. apply `./affine.env.ts` patches
AFFiNE.serverName = 'Shokis notes';
//
// /* Whether the server is deployed behind a HTTPS proxied environment */
AFFiNE.https = true;
// /* Domain of your server that your server will be available at */
AFFiNE.host = 'my.custom.domain';
// /* The local port of your server that will listen on */
AFFiNE.port = 3010;
AFFiNE.metrics.enabled = true;
AFFiNE.auth.allowSignup = true;
AFFiNE.plugins.use('oauth', {
providers: {
google: {
clientId: '[redacted].apps.googleusercontent.com',
clientSecret: 'G**SPX-***[redacted]***',
args: {
// See https://developers.google.com/identity/protocols/oauth2
scope: 'openid email profile',
promot: 'select_account',
access_type: 'offline',
},
},
},
});
my .envAFFINE_ADMIN_EMAIL=[redacted]
AFFINE_ADMIN_PASSWORD=[redacted]
#email
MAILER_HOST=smtp.gmail.com
MAILER_PASSWORD=[redacted]
MAILER_PORT=465
MAILER_SECURE=true
MAILER_SENDER=AFFiNE <[redacted]>
MAILER_USER=[redacted] |
Are there any other configs or logs you will need to help triage the problem? |
seems you not set |
Having the same issue here, the redirect url is hardcoded. I set AFFINE_SERVER_HOST btw |
I have, just removed original value in the |
To avoid that my assumptions is slowing this down, I have also tried to set |
I upgraded the container in my nas to the latest version today and reproduced this problem. I will troubleshoot this problem tomorrow |
Any news here? |
Do you need anything else from my end? |
@EYHN Can I be of assistance to add more information here in order to help you solve this? I appreciate your work, however, this is quite bad and it has been halting me from using Affine for the past months. |
I gave up on the tool |
Some update about it? |
It seems that only the link from the login button is problematic. After clicking "continue with xxx", modify the browser's URL by replacing |
I guess that I "solved" here. I don't know if it's the ideal but the button and login appears and sync with my cloud (google login). In my affine.js I just add the line I'm using on umbrel. docker-compose.yml services:
app_proxy:
environment:
APP_HOST: affine_web_1
APP_PORT: 3010
container_name: affine_app_proxy_1
web:
image: ghcr.io/toeverything/affine-graphql:stable-55db9f9
restart: on-failure
init: true
ports:
- '3010:3010'
- '5555:5555'
command:
- sh
- '-c'
- node ./scripts/self-host-predeploy && node ./dist/index.js
environment:
- NODE_OPTIONS="--import=./scripts/register.js"
- AFFINE_CONFIG_PATH=/root/.affine/config
- REDIS_SERVER_HOST=affine_redis_1
- DATABASE_URL=postgres://affine:affine@db:5432/affine
- NODE_ENV=production
- AFFINE_ADMIN_EMAIL=admin@umbrel.local
- AFFINE_ADMIN_PASSWORD=$APP_PASSWORD
- >-
OAUTH_GOOGLE_CLIENT_ID=<<YOUR CLIENT ID>>
- OAUTH_GOOGLE_CLIENT_SECRET=<<YOUR CLIENT SECRET>>
volumes:
- ${APP_DATA_DIR}/data/config:/root/.affine/config
- ${APP_DATA_DIR}/data/storage/blob:/root/.affine/storage
depends_on:
redis:
condition: service_healthy
db:
condition: service_healthy
container_name: affine_web_1
redis:
image: >-
redis:7.2.4@sha256:e647cfe134bf5e8e74e620f66346f93418acfc240b71dd85640325cb7cd01402
restart: on-failure
volumes:
- ${APP_DATA_DIR}/data/storage/redis:/data
healthcheck:
test:
- CMD
- redis-cli
- '--raw'
- incr
- ping
interval: 10s
timeout: 5s
retries: 5
container_name: affine_redis_1
db:
image: >-
postgres:16.2@sha256:f58300ac8d393b2e3b09d36ea12d7d24ee9440440e421472a300e929ddb63460
restart: on-failure
environment:
POSTGRES_USER: affine
POSTGRES_PASSWORD: affine
POSTGRES_DB: affine
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- ${APP_DATA_DIR}/data/storage/postgres:/var/lib/postgresql/data
healthcheck:
test:
- CMD-SHELL
- pg_isready -U affine
interval: 10s
timeout: 5s
retries: 5
container_name: affine_db_1 Edit 1: I faced up a bug after the login, the redirect goes to https://app.affine.pro, when I click on the button, redirects to home normally and sync. Anyone? |
we've checked the oauth url is truly hard coded with 'app.affine.pro' prefix in build time, and it is hard to distribute a fix for it. please allow me to mark oauth service unusable for selfhost instances for now. we will soon make it possible to connect to selfhost instances in official web/desktop client and provide a totally rewritten auth system. lets track it in #2646 and it's planned to be landed in 0.17.0! |
What happened?
Setting Google Client ID and Secret allows for the sign-in to work, but it redirects users to
app.affine.pro
and not back to my own instancenotes.example.com
.Can the redirect URI be overridden somewhere? Relevant snippet i found was this:
AFFiNE/packages/frontend/electron/src/main/ui/google-auth.ts
Line 7 in b8a1fbd
Client that logs in to my instance via google, is sent to the following URL:
https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?client_id=[redacted]&redirect_uri=https%3A%2F%2Fapp.affine.pro%2Foauth%2Fcallback&response_type=code&scope=openid%20email%20profile&prompt=select_account&access_type=offline&state=ea928a41-f952-45b9-94bd-371b457602aa&service=lso&o2v=2&ddm=0&flowName=GeneralOAuthFlow
Pay extra attention to "redirect_uri".
Possibly related to #6141?
I am also overriding the environment variable
AFFINE.host
with my own domain.I have attached a screenshot from my browser network log, it seems to attempt logging in to the public cloud instance;
Distribution version
Linux
What browsers are you seeing the problem on if you're using web version?
No response
Are you self-hosting?
Relevant log output
Anything else?
No response
The text was updated successfully, but these errors were encountered: