Skip to content

Custom auth/alban/react next sample app signin #7624

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

Open
wants to merge 18 commits into
base: custom-auth/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/msal-custom-auth/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
max_line_length = 140

[*.json]
indent_size = 2
Expand Down
70 changes: 0 additions & 70 deletions lib/msal-custom-auth/samples/signin/index.html

This file was deleted.

7 changes: 0 additions & 7 deletions lib/msal-custom-auth/src/CustomAuthPublicClientApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,5 @@ export class CustomAuthPublicClientApplication
`The authority URL '${config.auth?.authority}' is not a CIAM authority.`,
);
}

if (config.customAuth.authApiProxyUrl && !UrlUtils.IsValidSecureUrl(config.customAuth.authApiProxyUrl)) {
throw new InvalidConfigurationError(
InvalidAuthApiProxyDomain,
`The authApiProxyDomain URL '${config.customAuth.authApiProxyUrl}' is not a valid secure URL.`,
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export abstract class BaseApiClient {
private readonly clientId: string,
private httpClient: IHttpClient,
) {
this.baseRequestUrl = UrlUtils.parseSecureUrl(!baseUrl.endsWith("/") ? `${baseUrl}/` : baseUrl);
this.baseRequestUrl = UrlUtils.parseUrl(!baseUrl.endsWith("/") ? `${baseUrl}/` : baseUrl);
}

protected async request<T>(
Expand All @@ -37,7 +37,7 @@ export abstract class BaseApiClient {
let response: Response;

try {
response = await this.httpClient.post(url, formData, correlationId, headers);
response = await this.httpClient.post(url, formData, headers);
} catch (e) {
throw new CustomAuthApiError(
CustomAuthApiErrorCode.HTTP_REQUEST_FAILED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import { FailedSendRequest, HttpError, NoNetworkConnectivity } from "../../error
export class FetchHttpClient implements IHttpClient {
constructor(private logger: Logger) {}

async sendAsync(url: string | URL, options: RequestInit, correlationId: string): Promise<Response> {
async sendAsync(url: string | URL, options: RequestInit): Promise<Response> {
const headers = options.headers as Record<string, string>;
const correlationId = headers?.["client-request-id"] || undefined;

try {
this.logger.verbosePii(`Sending request to ${url}`, correlationId);

const startTime = performance.now();

const response = await fetch(url, options);

const endTime = performance.now();

this.logger.verbosePii(
Expand All @@ -40,31 +41,18 @@ export class FetchHttpClient implements IHttpClient {
}
}

async post(
url: string | URL,
body: RequestBody,
correlationId: string,
headers: Record<string, string> = {},
): Promise<Response> {
return this.sendAsync(
url,
{
method: HttpMethod.POST,
headers,
body,
},
correlationId,
);
async post(url: string | URL, body: RequestBody, headers: Record<string, string> = {}): Promise<Response> {
return this.sendAsync(url, {
method: HttpMethod.POST,
headers,
body,
});
}

async get(url: string | URL, correlationId: string, headers: Record<string, string> = {}): Promise<Response> {
return this.sendAsync(
url,
{
method: HttpMethod.GET,
headers,
},
correlationId,
);
async get(url: string | URL, headers: Record<string, string> = {}): Promise<Response> {
return this.sendAsync(url, {
method: HttpMethod.GET,
headers,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,23 @@ export interface IHttpClient {
* Sends a request.
* @param url The URL to send the request to.
* @param options Additional fetch options.
* @param correlationId The correlation ID for the request.
*/
sendAsync(url: string | URL, options: RequestInit, correlationId: string): Promise<Response>;
sendAsync(url: string | URL, options: RequestInit): Promise<Response>;

/**
* Sends a POST request.
* @param url The URL to send the request to.
* @param body The body of the request.
* @param correlationId The correlation ID for the request.
* @param headers Optional headers for the request.
*/
post(
url: string | URL,
body: RequestBody,
correlationId: string,
headers?: Record<string, string>,
): Promise<Response>;
post(url: string | URL, body: RequestBody, headers?: Record<string, string>): Promise<Response>;

/**
* Sends a GET request.
* @param url The URL to send the request to.
* @param correlationId The correlation ID for the request.
* @param headers Optional headers for the request.
*/
get(url: string | URL, correlationId: string, headers?: Record<string, string>): Promise<Response>;
get(url: string | URL, headers?: Record<string, string>): Promise<Response>;
}

/**
Expand Down
Loading