Skip to content

Commit 14c73e5

Browse files
authored
feat: remove supertokens-core and supertokens-node (#7705)
1 parent a4640db commit 14c73e5

40 files changed

Lines changed: 354 additions & 2191 deletions

.changeset/stale-knives-help.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
'hive': major
3+
---
4+
5+
**BREAKING** Remove support for `supertokens` service and replace it with native authentication solution.
6+
7+
## Upgrade Guide
8+
9+
Adjust your docker compose file like the following:
10+
- Remove `services.supertokens` from your `docker-compose.community.yml` file
11+
- Remove the following environment variables from the `services.server.environment`
12+
- `SUPERTOKENS_CONNECTION_URI=`
13+
- `SUPERTOKENS_API_KEY=`
14+
- Set the following environment variables for `services.server.environment`
15+
- `SUPERTOKENS_REFRESH_TOKEN_KEY=`
16+
- `SUPERTOKENS_ACCESS_TOKEN_KEY=`
17+
18+
### Set the refresh token key
19+
20+
#### Extract from existing `supertokens` deployment
21+
22+
This method works if you use supertokens before and want to have existing user sessions to continue working.
23+
If you want to avoid messing with the database, you can also create a new refresh token key from scratch, the drawback is that users are forced to login again.
24+
25+
Extract the refresh token key from the supertokens database
26+
```sql
27+
SELECT "value" FROM "supertokens_key_value" WHERE "name" = 'refresh_token_key';
28+
```
29+
30+
The key should look similar to this: `1000:15e5968d52a9a48921c1c63d88145441a8099b4a44248809a5e1e733411b3eeb80d87a6e10d3390468c222f6a91fef3427f8afc8b91ea1820ab10c7dfd54a268:39f72164821e08edd6ace99f3bd4e387f45fa4221fe3cd80ecfee614850bc5d647ac2fddc14462a00647fff78c22e8d01bc306a91294f5b889a90ba891bf0aa0`
31+
32+
Update the docker compose `services.server.environment.SUPERTOKENS_REFRESH_TOKEN_KEY` environment variable value to this string.
33+
34+
#### Create from scratch
35+
36+
Run the following command to create a new refresh key from scratch:
37+
38+
```sh
39+
echo "1000:$(openssl rand -hex 64):$(openssl rand -hex 64)"
40+
```
41+
42+
### Set the access token key
43+
44+
Generate a new access token key using the following instructions:
45+
46+
```sh
47+
# 1. Generate a unique key name. 'uuidgen' is great for this.
48+
# You can replace this with any string you like, e.g., KEY_NAME="my-app-key-1"
49+
KEY_NAME=$(uuidgen)
50+
# 2. Generate a 2048-bit RSA private key in PEM format, held in memory.
51+
PRIVATE_KEY_PEM=$(openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048)
52+
# 3. Extract the corresponding public key from the private key, also held in memory.
53+
PUBLIC_KEY_PEM=$(echo "$PRIVATE_KEY_PEM" | openssl rsa -pubout)
54+
# 4. Strip the headers/footers and newlines from the private key PEM
55+
# to get just the raw Base64 data.
56+
PRIVATE_KEY_DATA=$(echo "$PRIVATE_KEY_PEM" | awk 'NF {if (NR!=1 && $0!~/-----END/) print}' | tr -d '\n')
57+
# 5. Do the same for the public key PEM.
58+
PUBLIC_KEY_DATA=$(echo "$PUBLIC_KEY_PEM" | awk 'NF {if (NR!=1 && $0!~/-----END/) print}' | tr -d '\n')
59+
# 6. Echo the final formatted string to the console.
60+
echo "${KEY_NAME}|${PUBLIC_KEY_DATA}|${PRIVATE_KEY_DATA}"
61+
```
62+
63+
Update the docker compose `services.server.environment.SUPERTOKENS_ACCESS_TOKEN_KEY` environment variable value to the formatted string output.
64+
65+
## Conclusion
66+
67+
After performing this updates you can run Hive Console without the need for the `supertokens` service. All the relevant authentication logic resides within the `server` container instead.
68+
69+
Existing users in the supertokens system will continue to exist when running without the `supertokens` service.

cypress/e2e/app.cy.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ describe('oidc', () => {
250250
cy.clearAllLocalStorage();
251251
cy.clearAllSessionStorage();
252252
cy.visit('/auth/oidc?id=invalid');
253-
cy.get('[data-cy="auth-card-header-description"]').contains('Could not find OIDC integration.');
253+
cy.get('[data-cy="auth-card-header-description"]').contains(
254+
'Something went wrong. Please try again',
255+
);
254256
});
255257

256258
describe('requireInvitation', () => {
@@ -278,7 +280,7 @@ describe('oidc', () => {
278280

279281
// Check if OIDC authentication failed as intended
280282
cy.get(`a[href="/${slug}"]`).should('not.exist');
281-
cy.contains('not invited');
283+
cy.contains('Sign in not allowed.');
282284
});
283285
});
284286
});

deployment/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { deployS3, deployS3AuditLog, deployS3Mirror } from './services/s3';
2424
import { deploySchema } from './services/schema';
2525
import { configureSentry } from './services/sentry';
2626
import { configureSlackApp } from './services/slack-app';
27-
import { deploySuperTokens } from './services/supertokens';
2827
import { deployTokens } from './services/tokens';
2928
import { deployUsage } from './services/usage';
3029
import { deployUsageIngestor } from './services/usage-ingestor';
@@ -203,7 +202,6 @@ deployWorkflows({
203202
redis,
204203
});
205204

206-
const supertokens = deploySuperTokens(postgres, { dependencies: [dbMigrations] }, environment);
207205
const zendesk = configureZendesk({ environment });
208206
const githubApp = configureGithubApp();
209207
const slackApp = configureSlackApp();
@@ -222,7 +220,6 @@ const graphql = deployGraphQL({
222220
usage,
223221
cdn,
224222
commerce,
225-
supertokens,
226223
s3,
227224
s3Mirror,
228225
s3AuditLog,

deployment/services/db-migrations.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export function deployDbMigrations({
4747
// Since K8s job are immutable, we can't edit or ask K8s to re-run a Job, so we are doing a
4848
// pseudo change to an env var, which causes Pulumi to re-create the Job.
4949
IGNORE_RERUN_NONCE: force ? Date.now().toString() : '0',
50-
SUPERTOKENS_AT_HOME: '1',
5150
},
5251
},
5352
[clickhouse.deployment, clickhouse.service, ...(dependencies || [])],

deployment/services/environment.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ export function prepareEnvironment(input: {
4848
general: {
4949
replicas: isProduction || isStaging ? 3 : 1,
5050
},
51-
supertokens: {
52-
replicas: isProduction || isStaging ? 3 : 1,
53-
},
5451
envoy: {
5552
replicas: isProduction || isStaging ? 3 : 1,
5653
cpuLimit: isProduction ? '1500m' : '120m',

deployment/services/graphql.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { Redis } from './redis';
1616
import { S3 } from './s3';
1717
import { Schema } from './schema';
1818
import { Sentry } from './sentry';
19-
import { Supertokens } from './supertokens';
2019
import { Tokens } from './tokens';
2120
import { Usage } from './usage';
2221
import { Zendesk } from './zendesk';
@@ -40,7 +39,6 @@ export function deployGraphQL({
4039
usage,
4140
commerce,
4241
dbMigrations,
43-
supertokens,
4442
s3,
4543
s3Mirror,
4644
s3AuditLog,
@@ -68,7 +66,6 @@ export function deployGraphQL({
6866
usage: Usage;
6967
dbMigrations: DbMigrations;
7068
commerce: CommerceService;
71-
supertokens: Supertokens;
7269
zendesk: Zendesk;
7370
docker: Docker;
7471
sentry: Sentry;
@@ -144,7 +141,6 @@ export function deployGraphQL({
144141
ZENDESK_SUPPORT: zendesk.enabled ? '1' : '0',
145142
INTEGRATION_GITHUB: '1',
146143
// Auth
147-
SUPERTOKENS_CONNECTION_URI: supertokens.localEndpoint,
148144
AUTH_GITHUB: '1',
149145
AUTH_GOOGLE: '1',
150146
AUTH_ORGANIZATION_OIDC: '1',
@@ -155,7 +151,6 @@ export function deployGraphQL({
155151
? observability.tracingEndpoint
156152
: '',
157153
S3_MIRROR: '1',
158-
SUPERTOKENS_AT_HOME: '1',
159154
},
160155
exposesMetrics: true,
161156
port: 4000,
@@ -209,7 +204,6 @@ export function deployGraphQL({
209204
.withSecret('S3_AUDIT_LOG_BUCKET_NAME', s3AuditLog.secret, 'bucket')
210205
.withSecret('S3_AUDIT_LOG_ENDPOINT', s3AuditLog.secret, 'endpoint')
211206
// Auth
212-
.withSecret('SUPERTOKENS_API_KEY', supertokens.secret, 'apiKey')
213207
.withSecret('AUTH_GITHUB_CLIENT_ID', githubOAuthSecret, 'clientId')
214208
.withSecret('AUTH_GITHUB_CLIENT_SECRET', githubOAuthSecret, 'clientSecret')
215209
.withSecret('AUTH_GOOGLE_CLIENT_ID', googleOAuthSecret, 'clientId')

deployment/services/supertokens.ts

Lines changed: 0 additions & 109 deletions
This file was deleted.

docker/docker-compose.community.yml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,6 @@ services:
8989
volumes:
9090
- './.hive/redis/db:/bitnami/redis/data'
9191

92-
supertokens:
93-
image: registry.supertokens.io/supertokens/supertokens-postgresql:9.3
94-
depends_on:
95-
db:
96-
condition: service_healthy
97-
networks:
98-
- 'stack'
99-
environment:
100-
POSTGRESQL_USER: '${POSTGRES_USER}'
101-
POSTGRESQL_PASSWORD: '${POSTGRES_PASSWORD}'
102-
POSTGRESQL_DATABASE_NAME: '${POSTGRES_DB}'
103-
POSTGRESQL_TABLE_NAMES_PREFIX: 'supertokens'
104-
POSTGRESQL_HOST: db
105-
POSTGRESQL_PORT: 5432
106-
API_KEYS: '${SUPERTOKENS_API_KEY}'
107-
10892
s3:
10993
image: quay.io/minio/minio:RELEASE.2025-09-07T16-13-09Z
11094
command: server /data --console-address ":9001"
@@ -234,9 +218,9 @@ services:
234218
# Auth
235219
AUTH_ORGANIZATION_OIDC: '1'
236220
AUTH_REQUIRE_EMAIL_VERIFICATION: '0'
237-
SUPERTOKENS_CONNECTION_URI: http://supertokens:3567
238-
SUPERTOKENS_API_KEY: '${SUPERTOKENS_API_KEY}'
239221
GRAPHQL_PUBLIC_ORIGIN: http://localhost:8082
222+
SUPERTOKENS_REFRESH_TOKEN_KEY: '${SUPERTOKENS_REFRESH_TOKEN_KEY}'
223+
SUPERTOKENS_ACCESS_TOKEN_KEY: '${SUPERTOKENS_ACCESS_TOKEN_KEY}'
240224
# Tracing
241225
OPENTELEMETRY_COLLECTOR_ENDPOINT: '${OPENTELEMETRY_COLLECTOR_ENDPOINT:-}'
242226
SENTRY: '${SENTRY:-0}'

docker/docker-compose.dev.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -123,25 +123,6 @@ services:
123123
volumes:
124124
- ./.hive-dev/broker/db:/var/lib/kafka/data
125125

126-
supertokens:
127-
image: registry.supertokens.io/supertokens/supertokens-postgresql:9.3
128-
mem_limit: 300m
129-
depends_on:
130-
db:
131-
condition: service_healthy
132-
networks:
133-
- 'stack'
134-
ports:
135-
- '3567:3567'
136-
environment:
137-
POSTGRESQL_USER: postgres
138-
POSTGRESQL_PASSWORD: postgres
139-
POSTGRESQL_DATABASE_NAME: registry
140-
POSTGRESQL_TABLE_NAMES_PREFIX: 'supertokens'
141-
POSTGRESQL_HOST: db
142-
POSTGRESQL_PORT: 5432
143-
API_KEYS: bubatzbieber6942096420
144-
145126
oidc-server-mock:
146127
image: ghcr.io/soluto/oidc-server-mock:0.8.6
147128
mem_limit: 200m

docker/docker-compose.end2end.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ services:
3333
networks:
3434
- 'stack'
3535

36-
supertokens:
37-
ports:
38-
- '3567:3567'
39-
4036
db:
4137
ports:
4238
- '5432:5432'

0 commit comments

Comments
 (0)