Skip to content

Commit 68b7847

Browse files
committed
First working version of login post hydra/kratos upgrade
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent 49c9cce commit 68b7847

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

k8s/cloud/base/ory_auth/hydra/hydra_deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ spec:
127127
- name: SERVE_PUBLIC_CORS_ALLOWED_ORIGINS_1
128128
value: https://work.$(PL_DOMAIN_NAME)
129129
- name: PL_WORK_DOMAIN
130-
value: work.$(PL_DOMAIN_NAME):8080
130+
value: work.$(PL_DOMAIN_NAME)
131131
- name: PL_OAUTH_DOMAIN
132132
value: $(PL_WORK_DOMAIN)/oauth
133133
- name: HYDRA_URL

k8s/cloud/base/ory_auth/kratos/kratos_deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ spec:
100100
- name: LOG_LEVEL
101101
value: trace
102102
- name: PL_WORK_DOMAIN
103-
value: work.$(PL_DOMAIN_NAME):8080
103+
value: work.$(PL_DOMAIN_NAME)
104104
- name: PL_OAUTH_DOMAIN
105105
value: $(PL_WORK_DOMAIN)/oauth
106106
- name: FRONTEND_URL

src/ui/src/pages/auth/hydra-oauth-provider.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,20 @@ interface DynamicClientRegistrationResponse extends OAuth2Client {
101101
registration_access_token?: string;
102102
}
103103

104-
// Cache for the dynamically registered client ID
105-
let cachedClientId: string | null = null;
104+
// Cache key for storing the dynamic client ID in session storage
105+
const DYNAMIC_CLIENT_ID_KEY = 'hydra-dynamic-client-id';
106106

107107
async function getDynamicClientId(): Promise<string> {
108108
// Only use dynamic registration for hydra provider
109109
if (OAUTH_PROVIDER !== 'hydra') {
110110
return AUTH_CLIENT_ID;
111111
}
112112

113-
// Return cached client ID if available
114-
if (cachedClientId) {
115-
return cachedClientId;
113+
// Check session storage for existing client ID
114+
const storedClientId = sessionStorage.getItem(DYNAMIC_CLIENT_ID_KEY);
115+
if (storedClientId) {
116+
console.log('Using cached dynamic client ID from session storage:', storedClientId);
117+
return storedClientId;
116118
}
117119

118120
// Use /oauth/hydra prefix which will be stripped by the proxy
@@ -155,8 +157,8 @@ async function getDynamicClientId(): Promise<string> {
155157
throw new Error('No client_id returned from dynamic registration');
156158
}
157159

158-
// Cache the client ID for future use
159-
cachedClientId = data.client_id;
160+
// Store the client ID in session storage for use across page loads
161+
sessionStorage.setItem(DYNAMIC_CLIENT_ID_KEY, data.client_id);
160162

161163
console.log('Successfully registered dynamic OAuth2 client:', data.client_id);
162164
return data.client_id;

0 commit comments

Comments
 (0)