mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
feat: pass user agent to connector (#2770)
This commit is contained in:
parent
2a723f01a3
commit
396dce8c3d
3 changed files with 10 additions and 2 deletions
|
@ -28,8 +28,12 @@ export const createSocialAuthorizationUrl = async (
|
||||||
|
|
||||||
assertThat(connector.type === ConnectorType.Social, 'connector.unexpected_type');
|
assertThat(connector.type === ConnectorType.Social, 'connector.unexpected_type');
|
||||||
|
|
||||||
|
const {
|
||||||
|
headers: { 'user-agent': userAgent },
|
||||||
|
} = ctx.request;
|
||||||
|
|
||||||
return connector.getAuthorizationUri(
|
return connector.getAuthorizationUri(
|
||||||
{ state, redirectUri },
|
{ state, redirectUri, headers: { userAgent } },
|
||||||
async (connectorStorage: ConnectorSession) =>
|
async (connectorStorage: ConnectorSession) =>
|
||||||
assignConnectorSessionResult(ctx, provider, connectorStorage)
|
assignConnectorSessionResult(ctx, provider, connectorStorage)
|
||||||
);
|
);
|
||||||
|
|
|
@ -52,13 +52,16 @@ export default function socialRoutes<T extends AnonymousRouterLegacy>(
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
async (ctx, next) => {
|
async (ctx, next) => {
|
||||||
|
const {
|
||||||
|
headers: { 'user-agent': userAgent },
|
||||||
|
} = ctx.request;
|
||||||
await provider.interactionDetails(ctx.req, ctx.res);
|
await provider.interactionDetails(ctx.req, ctx.res);
|
||||||
const { connectorId, state, redirectUri } = ctx.guard.body;
|
const { connectorId, state, redirectUri } = ctx.guard.body;
|
||||||
assertThat(state && redirectUri, 'session.insufficient_info');
|
assertThat(state && redirectUri, 'session.insufficient_info');
|
||||||
const connector = await getLogtoConnectorById(connectorId);
|
const connector = await getLogtoConnectorById(connectorId);
|
||||||
assertThat(connector.type === ConnectorType.Social, 'connector.unexpected_type');
|
assertThat(connector.type === ConnectorType.Social, 'connector.unexpected_type');
|
||||||
const redirectTo = await connector.getAuthorizationUri(
|
const redirectTo = await connector.getAuthorizationUri(
|
||||||
{ state, redirectUri },
|
{ state, redirectUri, headers: { userAgent } },
|
||||||
async (connectorStorage: ConnectorSession) =>
|
async (connectorStorage: ConnectorSession) =>
|
||||||
assignConnectorSessionResult(ctx, provider, connectorStorage)
|
assignConnectorSessionResult(ctx, provider, connectorStorage)
|
||||||
);
|
);
|
||||||
|
|
|
@ -166,6 +166,7 @@ export type GetAuthorizationUri = (
|
||||||
payload: {
|
payload: {
|
||||||
state: string;
|
state: string;
|
||||||
redirectUri: string;
|
redirectUri: string;
|
||||||
|
headers?: { userAgent?: string };
|
||||||
},
|
},
|
||||||
setSession?: SetSession
|
setSession?: SetSession
|
||||||
) => Promise<string>;
|
) => Promise<string>;
|
||||||
|
|
Loading…
Add table
Reference in a new issue