Skip to content

Commit

Permalink
Merge pull request #62 from sebadob/impl-peer-ip-in-session-response
Browse files Browse the repository at this point in the history
Impl peer ip in session response
  • Loading branch information
sebadob committed Sep 29, 2023
2 parents 2b0a629 + 6ca7552 commit 828bcd2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 77 deletions.
159 changes: 82 additions & 77 deletions frontend/src/components/admin/sessions/Sessions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@
label: 'Session ID',
callback: (item, search) => item.id.toLowerCase().includes(search.toLowerCase()),
},
{
label: 'IP',
callback: (item, search) => item.remote_ip?.toLowerCase().includes(search.toLowerCase()),
},
];
let orderOptions = [
{label: 'Expires', callback: (a, b) => a.exp - b.exp},
{label: 'Last Seen', callback: (a, b) => a.last_seen - b.last_seen},
{label: 'Session ID', callback: (a, b) => a.id.localeCompare(b.id)},
{label: 'User ID', callback: (a, b) => a.user_id?.localeCompare(b.user_id)},
{label: 'State', callback: (a, b) => a.state.localeCompare(b.state)},
{label: 'IP', callback: (a, b) => a.remote_ip?.localeCompare(b.remote_ip)},
];
onMount(async () => {
Expand Down Expand Up @@ -81,76 +86,52 @@
orderOptions={orderOptions}
firstDirReverse
/>
<div class="button">
<div class="button" style:margin-top="-10px">
<Button on:click={invalidateSessions} level={3}>
Invalidate All Sessions
</Button>
</div>
</div>
<!-- header-->
<div class="row">
<div class="c1">
<b>
Session ID
</b>
</div>
<div class="c2">
<b>
User ID
</b>
</div>
<div class="c3">
<b>
State
</b>
</div>
<div class="c4">
<b>
MFA
</b>
</div>
<div class="c5">
<b>
Expires
</b>
</div>
<div class="c6">
<b>
Last Seen
</b>
</div>
</div>
{#each resSessions as session}
<div class={session.exp > now ? 'entryRow' : 'entryRow expired'}>
<div class="c1 font-mono">
{session.id}
</div>
<div class="c2 font-mono">
{session.user_id}
<div class="row1">
<div class="col-sid flex font-mono">
<div class="label" style:margin-right=".75rem">SID:</div>
{session.id}
</div>
<div class="col-exp flex">
<div class="label">EXP:</div>
{formatDateFromTs(session.exp)}
</div>
<div class="col-seen flex">
<div class="label">SEEN:</div>
{formatDateFromTs(session.last_seen)}
</div>
</div>
<div class="c3">
{session.state}
</div>
<div class="c4">
<CheckIcon check={session.is_mfa}/>
</div>
<div class="c5">
{formatDateFromTs(session.exp)}
</div>
<div class="c6">
{formatDateFromTs(session.last_seen)}
<div class="row2">
<div class="col-uid flex font-mono">
<div class="label">USER:</div>
{session.user_id}
</div>
<div class="col-state flex">
<div class="label">STATE:</div>
{session.state}
</div>
<div class="col-ip flex">
<div class="label">IP:</div>
{session.remote_ip}
</div>
<div class="col-mfa flex">
<div class="label">MFA:</div>
<CheckIcon check={session.is_mfa}/>
</div>
</div>
</div>
{/each}
Expand All @@ -162,44 +143,68 @@
margin: 10px 0 0 25px;
}
.c1 {
width: 325px;
margin-left: 5px;
.col-sid {
width: 23rem;
}
.col-uid {
width: 23rem;
}
.c2 {
width: 240px;
.col-state {
width: 12.25rem;
}
.c3 {
width: 90px;
.col-mfa {
width: 4.5rem;
}
.c4 {
width: 45px;
.col-exp {
width: 12.25rem;
}
.c5 {
width: 160px;
.col-seen {
width: 13rem;
}
.c6 {
width: 160px;
.col-ip {
width: 9.75rem;
}
.expired {
background: var(--col-gmid);
}
.row, .entryRow {
.flex {
display: flex;
justify-content: space-between;
width: 1023px;
border-bottom: 1px solid var(--col-gmid);
align-items: center;
}
.label {
margin-right: .25rem;
font-weight: bold;
font-size: .9rem;
}
.entryRow {
max-width: 50rem;
margin-bottom: 1rem;
}
.entryRow:hover {
background: var(--col-acnt);
color: white
}
.row1, .row2 {
display: inline-flex;
flex-wrap: wrap;
flex: 1;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
}
</style>
1 change: 1 addition & 0 deletions rauthy-handlers/src/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub async fn get_sessions(
state: &s.state,
exp: s.exp,
last_seen: s.last_seen,
remote_ip: s.remote_ip.as_deref(),
})
.collect::<Vec<SessionResponse>>();
Ok(HttpResponse::Ok().json(resp))
Expand Down
1 change: 1 addition & 0 deletions rauthy-models/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ pub struct SessionResponse<'a> {
pub state: &'a SessionState,
pub exp: i64,
pub last_seen: i64,
pub remote_ip: Option<&'a str>,
}

#[derive(Debug, Serialize, ToSchema)]
Expand Down

0 comments on commit 828bcd2

Please sign in to comment.