0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

feat: pass user agent to connector (#2770)

This commit is contained in:
Darcy Ye 2022-12-30 16:05:32 +08:00 committed by GitHub
parent 2a723f01a3
commit 396dce8c3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View file

@ -28,8 +28,12 @@ export const createSocialAuthorizationUrl = async (
assertThat(connector.type === ConnectorType.Social, 'connector.unexpected_type');
const {
headers: { 'user-agent': userAgent },
} = ctx.request;
return connector.getAuthorizationUri(
{ state, redirectUri },
{ state, redirectUri, headers: { userAgent } },
async (connectorStorage: ConnectorSession) =>
assignConnectorSessionResult(ctx, provider, connectorStorage)
);

View file

@ -52,13 +52,16 @@ export default function socialRoutes<T extends AnonymousRouterLegacy>(
}),
}),
async (ctx, next) => {
const {
headers: { 'user-agent': userAgent },
} = ctx.request;
await provider.interactionDetails(ctx.req, ctx.res);
const { connectorId, state, redirectUri } = ctx.guard.body;
assertThat(state && redirectUri, 'session.insufficient_info');
const connector = await getLogtoConnectorById(connectorId);
assertThat(connector.type === ConnectorType.Social, 'connector.unexpected_type');
const redirectTo = await connector.getAuthorizationUri(
{ state, redirectUri },
{ state, redirectUri, headers: { userAgent } },
async (connectorStorage: ConnectorSession) =>
assignConnectorSessionResult(ctx, provider, connectorStorage)
);

View file

@ -166,6 +166,7 @@ export type GetAuthorizationUri = (
payload: {
state: string;
redirectUri: string;
headers?: { userAgent?: string };
},
setSession?: SetSession
) => Promise<string>;