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

Adding redirect uri to connect client #1516

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions web/src/ConnectClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
WebStorageStateStore,
OidcClient,
OidcClientSettings,
WebStorageStateStore,
} from "oidc-client-ts";

export interface MobileDetect {
Expand Down Expand Up @@ -240,18 +240,23 @@ import MicroModal from "micromodal";

export class ConnectClient {
public baseUrl: string;
public redirectUri?: string;

public oidcConfig: OidcClientSettings;
oidcClient?: OidcClient;
popupWindow?: Window | null;

constructor(connectUrl: string = "https://connect.trinsic.cloud") {
constructor(
connectUrl: string = "https://connect.trinsic.cloud",
redirectUri?: string
) {
this.baseUrl = connectUrl;
this.redirectUri = redirectUri;

this.oidcConfig = {
authority: this.baseUrl,
client_id: "http://localhost:8080/",
Copy link
Member

@geel9 geel9 Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't part of the PR, but this seems... wrong for something we're shipping to customers. Is it possible to just elide this parameter if not provided?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as it's required for OIDC. We can change it to something else.

redirect_uri: "http://localhost:8080/",
redirect_uri: this.redirectUri ?? "http://localhost:8080/",

response_type: "code",
scope: "openid",
Expand Down Expand Up @@ -329,7 +334,15 @@ export class ConnectClient {
const iframe = document.createElement("iframe");
iframe.className = "h-full w-full bg-transparent";
iframe.allow = "camera *; microphone *; display-capture *";
iframe.src = `${this.baseUrl}/connect/verify?clientToken=${clientToken}`;

let redirectUri = "";
if (this.redirectUri) {
redirectUri = `&redirect_uri=${encodeURIComponent(
this.redirectUri
)}`;
}

iframe.src = `${this.baseUrl}/connect/verify?clientToken=${clientToken}${redirectUri}`;

modalContainer.append(iframe);
bgOverlay.append(modalContainer);
Expand Down