@@ -19,6 +19,16 @@ CREATE TYPE plan_interval AS ENUM ('day', 'month', 'year');
1919-- Origin - Allow specific IP addresses or URLs
2020CREATE TYPE allowlist_type AS ENUM (' service_id' , ' contract' , ' origin' );
2121
22+ -- Add support for multiple auth providers offering different types
23+ -- Must be updated to extend authorization to other providers.
24+ --
25+ -- Grove's portal uses Auth0 for authentication as of 09/2025.
26+ --
27+ -- Envoy Gateway has native support for other OIDC authentication types: https://gateway.envoyproxy.io/docs/tasks/security/oidc/
28+ -- For legacy support, only adding auth0 and its relevant types
29+ CREATE TYPE portal_auth_provider AS ENUM (' auth0' );
30+ CREATE TYPE portal_auth_type AS ENUM (' auth0_github' , ' auth0_username' , ' auth0_google' );
31+
2232-- ============================================================================
2333-- CORE ORGANIZATIONAL TABLES
2434-- ============================================================================
@@ -71,7 +81,7 @@ COMMENT ON COLUMN portal_plans.plan_rate_limit_rps IS 'Rate limit in requests pe
7181-- Portal Accounts can have many applications and many users. Only 1 user can be the OWNER.
7282-- When a new user signs up in the Portal, they automatically generate a personal account.
7383CREATE TABLE portal_accounts (
74- portal_account_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
84+ portal_account_id VARCHAR ( 36 ) PRIMARY KEY DEFAULT gen_random_uuid(),
7585 organization_id INT ,
7686 portal_plan_type VARCHAR (42 ) NOT NULL ,
7787 user_account_name VARCHAR (42 ),
@@ -101,7 +111,7 @@ COMMENT ON COLUMN portal_accounts.stripe_subscription_id IS 'Stripe subscription
101111-- Portal users table
102112-- Users can belong to multiple Accounts
103113CREATE TABLE portal_users (
104- portal_user_id SERIAL PRIMARY KEY ,
114+ portal_user_id VARCHAR ( 36 ) PRIMARY KEY ,
105115 portal_user_email VARCHAR (255 ) NOT NULL UNIQUE,
106116 signed_up BOOLEAN DEFAULT FALSE,
107117 portal_admin BOOLEAN DEFAULT FALSE,
@@ -118,12 +128,29 @@ COMMENT ON COLUMN portal_users.portal_admin IS 'Whether user has admin privilege
118128-- TODO_CONSIDERATION: Add support for MFA/2FA
119129-- TODO_CONSIDERATION: Consider session management table
120130
131+ -- Portal User Auth Table
132+ -- Determines which Auth Provider (portal_auth_provider) and which Auth Type
133+ -- (portal_auth_type) a user is authenticated into the Portal by
134+ CREATE TABLE portal_user_auth (
135+ portal_user_auth_id SERIAL PRIMARY KEY ,
136+ portal_user_id VARCHAR (42 ),
137+ portal_auth_provider portal_auth_provider,
138+ portal_auth_type portal_auth_type,
139+ auth_provider_user_id VARCHAR (69 ),
140+ federated BOOL DEFAULT FALSE,
141+ created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP ,
142+ updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP ,
143+ FOREIGN KEY (portal_user_id) REFERENCES portal_users(portal_user_id) ON DELETE CASCADE
144+ );
145+
146+ COMMENT ON TABLE portal_user_auth IS ' Authorization provider and type for each user. Determines how to authenticate a user into the Portal.' ;
147+
121148-- Contacts table
122149-- Contacts are individuals that are members of an Organization. Can be attached to Portal Users
123150CREATE TABLE contacts (
124151 contact_id SERIAL PRIMARY KEY ,
125152 organization_id INT ,
126- portal_user_id INT ,
153+ portal_user_id VARCHAR ( 36 ) ,
127154 contact_telegram_handle VARCHAR (32 ),
128155 contact_twitter_handle VARCHAR (15 ),
129156 contact_linkedin_handle VARCHAR (30 ),
@@ -156,8 +183,8 @@ COMMENT ON TABLE rbac IS 'Role definitions and their associated permissions';
156183-- Sets the role and access controls for a user on a particular account.
157184CREATE TABLE portal_account_rbac (
158185 id SERIAL PRIMARY KEY ,
159- portal_account_id UUID NOT NULL ,
160- portal_user_id INT NOT NULL ,
186+ portal_account_id VARCHAR ( 36 ) NOT NULL ,
187+ portal_user_id VARCHAR ( 36 ) NOT NULL ,
161188 role_name VARCHAR (20 ) NOT NULL ,
162189 user_joined_account BOOLEAN DEFAULT FALSE,
163190 FOREIGN KEY (portal_account_id) REFERENCES portal_accounts(portal_account_id) ON DELETE CASCADE ,
@@ -174,8 +201,8 @@ COMMENT ON TABLE portal_account_rbac IS 'User roles and permissions for specific
174201-- Portal applications table
175202-- Portal Accounts can have many Portal Applications that have associated settings.
176203CREATE TABLE portal_applications (
177- portal_application_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
178- portal_account_id UUID NOT NULL ,
204+ portal_application_id VARCHAR ( 36 ) PRIMARY KEY DEFAULT gen_random_uuid(),
205+ portal_account_id VARCHAR ( 36 ) NOT NULL ,
179206 portal_application_name VARCHAR (42 ),
180207 emoji VARCHAR (16 ),
181208 portal_application_user_limit INT CHECK (portal_application_user_limit >= 0 ),
@@ -202,8 +229,8 @@ COMMENT ON COLUMN portal_applications.secret_key_hash IS 'Hashed secret key for
202229-- Users must be members of the parent Account in order to have access to a particular application
203230CREATE TABLE portal_application_rbac (
204231 id SERIAL PRIMARY KEY ,
205- portal_application_id UUID NOT NULL ,
206- portal_user_id INT NOT NULL ,
232+ portal_application_id VARCHAR ( 36 ) NOT NULL ,
233+ portal_user_id VARCHAR ( 36 ) NOT NULL ,
207234 created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP ,
208235 updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP ,
209236 FOREIGN KEY (portal_application_id) REFERENCES portal_applications(portal_application_id) ON DELETE CASCADE ,
@@ -268,14 +295,18 @@ CREATE TABLE services (
268295 service_owner_address VARCHAR (50 ),
269296 network_id VARCHAR (42 ),
270297 active BOOLEAN DEFAULT FALSE,
298+ beta BOOLEAN DEFAULT FALSE,
299+ coming_soon BOOLEAN DEFAULT FALSE,
271300 quality_fallback_enabled BOOLEAN DEFAULT FALSE,
272301 hard_fallback_enabled BOOLEAN DEFAULT FALSE,
273302 svg_icon TEXT ,
303+ public_endpoint_url VARCHAR (169 ),
304+ status_endpoint_url VARCHAR (169 ),
305+ status_query TEXT ,
274306 deleted_at TIMESTAMPTZ ,
275307 created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP ,
276308 updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP ,
277- FOREIGN KEY (network_id) REFERENCES networks(network_id),
278- FOREIGN KEY (service_owner_address) REFERENCES gateways(gateway_address)
309+ FOREIGN KEY (network_id) REFERENCES networks(network_id)
279310);
280311
281312COMMENT ON TABLE services IS ' Supported blockchain services from the Pocket Network' ;
@@ -342,7 +373,7 @@ COMMENT ON COLUMN applications.application_address IS 'Blockchain address of the
342373-- Sets access controls to Portal Applications based on allowlist_type
343374CREATE TABLE portal_application_allowlists (
344375 id SERIAL PRIMARY KEY ,
345- portal_application_id UUID NOT NULL ,
376+ portal_application_id VARCHAR ( 36 ) NOT NULL ,
346377 type allowlist_type,
347378 value VARCHAR (255 ),
348379 service_id VARCHAR (42 ),
0 commit comments