You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-10 15:23:07 +03:00
Display IP address on sessions
This commit is contained in:
committed by
Quentin Gliech
parent
0896757a63
commit
127bf91b54
@@ -51,6 +51,7 @@ export const BasicSession: Story = {
|
|||||||
args: {
|
args: {
|
||||||
...defaultProps,
|
...defaultProps,
|
||||||
name: "KlTqK9CRt3",
|
name: "KlTqK9CRt3",
|
||||||
|
ipAddress: "2001:8003:c4614:f501:3091:888a:49c7",
|
||||||
clientName: "Element",
|
clientName: "Element",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -56,6 +56,20 @@ describe("<Session />", () => {
|
|||||||
{...defaultProps}
|
{...defaultProps}
|
||||||
finishedAt={finishedAt}
|
finishedAt={finishedAt}
|
||||||
clientName={clientName}
|
clientName={clientName}
|
||||||
|
clientLogoUri="https://client.org/logo.png"
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
expect(component.toJSON()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders ip address", () => {
|
||||||
|
const clientName = "Element";
|
||||||
|
const component = create(
|
||||||
|
<Session
|
||||||
|
{...defaultProps}
|
||||||
|
finishedAt={finishedAt}
|
||||||
|
clientName={clientName}
|
||||||
|
ipAddress="127.0.0.1"
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
expect(component.toJSON()).toMatchSnapshot();
|
expect(component.toJSON()).toMatchSnapshot();
|
||||||
|
@@ -33,6 +33,7 @@ export type SessionProps = {
|
|||||||
clientName?: string;
|
clientName?: string;
|
||||||
clientLogoUri?: string;
|
clientLogoUri?: string;
|
||||||
isCurrent?: boolean;
|
isCurrent?: boolean;
|
||||||
|
ipAddress?: string;
|
||||||
};
|
};
|
||||||
const Session: React.FC<React.PropsWithChildren<SessionProps>> = ({
|
const Session: React.FC<React.PropsWithChildren<SessionProps>> = ({
|
||||||
id,
|
id,
|
||||||
@@ -41,6 +42,7 @@ const Session: React.FC<React.PropsWithChildren<SessionProps>> = ({
|
|||||||
finishedAt,
|
finishedAt,
|
||||||
clientName,
|
clientName,
|
||||||
clientLogoUri,
|
clientLogoUri,
|
||||||
|
ipAddress,
|
||||||
isCurrent,
|
isCurrent,
|
||||||
children,
|
children,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -58,6 +60,7 @@ const Session: React.FC<React.PropsWithChildren<SessionProps>> = ({
|
|||||||
Finished <DateTime datetime={finishedAt} />
|
Finished <DateTime datetime={finishedAt} />
|
||||||
</SessionMetadata>
|
</SessionMetadata>
|
||||||
)}
|
)}
|
||||||
|
{!!ipAddress && <SessionMetadata>{ipAddress}</SessionMetadata>}
|
||||||
{!!clientName && (
|
{!!clientName && (
|
||||||
<SessionMetadata>
|
<SessionMetadata>
|
||||||
<ClientAvatar
|
<ClientAvatar
|
||||||
|
@@ -57,6 +57,55 @@ exports[`<Session /> > renders an active session 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`<Session /> > renders ip address 1`] = `
|
||||||
|
<div
|
||||||
|
className="_block_17898c"
|
||||||
|
>
|
||||||
|
<h6
|
||||||
|
className="_font-body-md-semibold_1jx6b_64 _sessionName_634806"
|
||||||
|
title="session-id"
|
||||||
|
>
|
||||||
|
session-id
|
||||||
|
</h6>
|
||||||
|
<p
|
||||||
|
className="_font-body-sm-semibold_1jx6b_45 _sessionMetadata_634806"
|
||||||
|
>
|
||||||
|
Signed in
|
||||||
|
<time
|
||||||
|
dateTime="2023-06-29T03:35:17Z"
|
||||||
|
>
|
||||||
|
Thu, 29 Jun 2023, 03:35
|
||||||
|
</time>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
className="_font-body-sm-semibold_1jx6b_45 _sessionMetadata_634806"
|
||||||
|
data-finished={true}
|
||||||
|
>
|
||||||
|
Finished
|
||||||
|
<time
|
||||||
|
dateTime="2023-06-29T03:35:19Z"
|
||||||
|
>
|
||||||
|
Thu, 29 Jun 2023, 03:35
|
||||||
|
</time>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
className="_font-body-sm-regular_1jx6b_40 _sessionMetadata_634806"
|
||||||
|
>
|
||||||
|
127.0.0.1
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
className="_font-body-sm-regular_1jx6b_40 _sessionMetadata_634806"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span
|
||||||
|
className="_font-body-sm-semibold_1jx6b_45 _sessionMetadata_634806"
|
||||||
|
>
|
||||||
|
Element
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`<Session /> > uses client name when truthy 1`] = `
|
exports[`<Session /> > uses client name when truthy 1`] = `
|
||||||
<div
|
<div
|
||||||
className="_block_17898c"
|
className="_block_17898c"
|
||||||
@@ -91,6 +140,17 @@ exports[`<Session /> > uses client name when truthy 1`] = `
|
|||||||
<p
|
<p
|
||||||
className="_font-body-sm-regular_1jx6b_40 _sessionMetadata_634806"
|
className="_font-body-sm-regular_1jx6b_40 _sessionMetadata_634806"
|
||||||
>
|
>
|
||||||
|
<img
|
||||||
|
alt="Element"
|
||||||
|
className="_avatar_39aee3"
|
||||||
|
referrerPolicy="no-referrer"
|
||||||
|
src="https://client.org/logo.png"
|
||||||
|
style={
|
||||||
|
{
|
||||||
|
"--mas-avatar-size": "var(--cpd-space-4x)",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
className="_font-body-sm-semibold_1jx6b_45 _sessionMetadata_634806"
|
className="_font-body-sm-semibold_1jx6b_45 _sessionMetadata_634806"
|
||||||
|
@@ -49,6 +49,10 @@ const BrowserSessionDetail: React.FC<Props> = ({ session }) => {
|
|||||||
? [{ label: "Finished", value: <DateTime datetime={data.finishedAt} /> }]
|
? [{ label: "Finished", value: <DateTime datetime={data.finishedAt} /> }]
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
const ipAddress = data.ipAddress
|
||||||
|
? [{ label: "IP Address", value: <code>{data.ipAddress}</code> }]
|
||||||
|
: [];
|
||||||
|
|
||||||
const lastAuthentication = data.lastAuthentication
|
const lastAuthentication = data.lastAuthentication
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
@@ -64,6 +68,7 @@ const BrowserSessionDetail: React.FC<Props> = ({ session }) => {
|
|||||||
{ label: "User Name", value: <code>{data.user.username}</code> },
|
{ label: "User Name", value: <code>{data.user.username}</code> },
|
||||||
{ label: "Signed in", value: <DateTime datetime={data.createdAt} /> },
|
{ label: "Signed in", value: <DateTime datetime={data.createdAt} /> },
|
||||||
...finishedAt,
|
...finishedAt,
|
||||||
|
...ipAddress,
|
||||||
...lastAuthentication,
|
...lastAuthentication,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -43,11 +43,17 @@ const CompatSessionDetail: React.FC<Props> = ({ session }) => {
|
|||||||
const finishedAt = data.finishedAt
|
const finishedAt = data.finishedAt
|
||||||
? [{ label: "Finished", value: <DateTime datetime={data.finishedAt} /> }]
|
? [{ label: "Finished", value: <DateTime datetime={data.finishedAt} /> }]
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
const ipAddress = data.ipAddress
|
||||||
|
? [{ label: "IP Address", value: <code>{data.ipAddress}</code> }]
|
||||||
|
: [];
|
||||||
|
|
||||||
const sessionDetails = [
|
const sessionDetails = [
|
||||||
{ label: "ID", value: <code>{data.id}</code> },
|
{ label: "ID", value: <code>{data.id}</code> },
|
||||||
{ label: "Device ID", value: <code>{data.deviceId}</code> },
|
{ label: "Device ID", value: <code>{data.deviceId}</code> },
|
||||||
{ label: "Signed in", value: <DateTime datetime={data.createdAt} /> },
|
{ label: "Signed in", value: <DateTime datetime={data.createdAt} /> },
|
||||||
...finishedAt,
|
...finishedAt,
|
||||||
|
...ipAddress,
|
||||||
];
|
];
|
||||||
|
|
||||||
const clientDetails: { label: string; value: string | JSX.Element }[] = [];
|
const clientDetails: { label: string; value: string | JSX.Element }[] = [];
|
||||||
|
@@ -45,19 +45,25 @@ const OAuth2SessionDetail: React.FC<Props> = ({ session }) => {
|
|||||||
const finishedAt = data.finishedAt
|
const finishedAt = data.finishedAt
|
||||||
? [{ label: "Finished", value: <DateTime datetime={data.createdAt} /> }]
|
? [{ label: "Finished", value: <DateTime datetime={data.createdAt} /> }]
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
const ipAddress = data.ipAddress
|
||||||
|
? [{ label: "IP Address", value: <code>{data.ipAddress}</code> }]
|
||||||
|
: [];
|
||||||
|
|
||||||
const sessionDetails = [
|
const sessionDetails = [
|
||||||
{ label: "ID", value: <code>{data.id}</code> },
|
{ label: "ID", value: <code>{data.id}</code> },
|
||||||
{ label: "Device ID", value: <code>{deviceId}</code> },
|
{ label: "Device ID", value: <code>{deviceId}</code> },
|
||||||
{ label: "Signed in", value: <DateTime datetime={data.createdAt} /> },
|
{ label: "Signed in", value: <DateTime datetime={data.createdAt} /> },
|
||||||
...finishedAt,
|
...finishedAt,
|
||||||
|
...ipAddress,
|
||||||
{
|
{
|
||||||
label: "Scopes",
|
label: "Scopes",
|
||||||
value: (
|
value: (
|
||||||
<>
|
<div>
|
||||||
{scopes.map((scope) => (
|
{scopes.map((scope) => (
|
||||||
<code key={scope}>{scope}</code>
|
<code key={scope}>{scope}</code>
|
||||||
))}
|
))}
|
||||||
</>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@@ -105,6 +105,7 @@ exports[`<OAuth2SessionDetail> > renders session details 1`] = `
|
|||||||
<p
|
<p
|
||||||
class="_font-body-sm-regular_1jx6b_40 _detailValue_040867"
|
class="_font-body-sm-regular_1jx6b_40 _detailValue_040867"
|
||||||
>
|
>
|
||||||
|
<div>
|
||||||
<code>
|
<code>
|
||||||
openid
|
openid
|
||||||
</code>
|
</code>
|
||||||
@@ -114,6 +115,7 @@ exports[`<OAuth2SessionDetail> > renders session details 1`] = `
|
|||||||
<code>
|
<code>
|
||||||
urn:matrix:org.matrix.msc2967.client:device:abcd1234
|
urn:matrix:org.matrix.msc2967.client:device:abcd1234
|
||||||
</code>
|
</code>
|
||||||
|
</div>
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -122,7 +122,7 @@ export default defineConfig((env) => ({
|
|||||||
proxy: {
|
proxy: {
|
||||||
// Routes mostly extracted from crates/router/src/endpoints.rs
|
// Routes mostly extracted from crates/router/src/endpoints.rs
|
||||||
"^/(|graphql.*|assets.*|\\.well-known.*|oauth2.*|login.*|logout.*|register.*|reauth.*|add-email.*|verify-email.*|change-password.*|consent.*|_matrix.*|complete-compat-sso.*)$":
|
"^/(|graphql.*|assets.*|\\.well-known.*|oauth2.*|login.*|logout.*|register.*|reauth.*|add-email.*|verify-email.*|change-password.*|consent.*|_matrix.*|complete-compat-sso.*)$":
|
||||||
"http://127.0.0.1:8080",
|
"https://auth-oidc.lab.element.dev",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user