Liking cljdoc? Tell your friends :D

wagoe.user.core.session

Functional Core - Pure session business logic - Minimal working version

Functional Core - Pure session business logic - Minimal working version
raw docstring

account-refusalclj

(account-refusal user)

Why user (nil when gone) may not authenticate, or nil.

Why `user` (nil when gone) may not authenticate, or nil.
sourceraw docstring

analyze-session-durationclj

(analyze-session-duration session now)

Calculate session duration in hours from creation to last access.

Calculate session duration in hours from creation to last access.
sourceraw docstring

calculate-session-risk-scoreclj

(calculate-session-risk-score session previous-sessions)

Calculate a 0.0-1.0 risk score based on IP changes and concurrent sessions.

Calculate a 0.0-1.0 risk score based on IP changes and concurrent sessions.
sourceraw docstring

calculate-user-session-statsclj

(calculate-user-session-stats sessions user-id)

Compute active/inactive session counts for a given user-id.

Compute active/inactive session counts for a given user-id.
sourceraw docstring

default-max-session-daysclj

How long a session lasts from sign-in, however it is used (BOU-1007).

How long a session lasts from sign-in, however it is used (BOU-1007).
sourceraw docstring

detect-suspicious-activity?clj

(detect-suspicious-activity? session previous-sessions)

Detect suspicious patterns (IP change, concurrent sessions) between current and previous sessions.

Detect suspicious patterns (IP change, concurrent sessions) between current and previous sessions.
sourceraw docstring

ends-atclj

(ends-at session max-days)

When session ends however it is used: max-days after sign-in. Nil for one that does not say when it began.

When `session` ends however it is used: `max-days` after sign-in. Nil for
one that does not say when it began.
sourceraw docstring

extend-pathclj

Where the page says the user is still there (BOU-1007).

Where the page says the user is still there (BOU-1007).
sourceraw docstring

extract-device-infoclj

(extract-device-info user-agent ip-address)

Parse user-agent and ip-address into a device-info map with :device-type.

Parse user-agent and ip-address into a device-info map with :device-type.
sourceraw docstring

filter-sessions-for-cleanupclj

(filter-sessions-for-cleanup sessions current-time)

Return sessions that have been expired past the cleanup grace period.

Return sessions that have been expired past the cleanup grace period.
sourceraw docstring

generate-session-tokenclj

(generate-session-token timestamp-ms nonce)

Build a deterministic session token from a timestamp and nonce.

Build a deterministic session token from a timestamp and nonce.
sourceraw docstring

group-sessions-by-device-typeclj

(group-sessions-by-device-type sessions)

Group sessions into :mobile, :desktop, or :other based on user-agent.

Group sessions into :mobile, :desktop, or :other based on user-agent.
sourceraw docstring

is-same-device?clj

(is-same-device? device1 device2)

Check if two device-info maps represent the same device (same IP and similar user-agent).

Check if two device-info maps represent the same device (same IP and similar user-agent).
sourceraw docstring

is-session-valid?clj

(is-session-valid? session current-time max-days)

Check if session is valid: not nil, not revoked, not expired, and within max-days of sign-in (BOU-1007).

Check if session is valid: not nil, not revoked, not expired, and within
`max-days` of sign-in (BOU-1007).
sourceraw docstring

mark-session-for-cleanupclj

(mark-session-for-cleanup session current-time)

Mark session as revoked by setting :revoked-at to current time.

Mark session as revoked by setting :revoked-at to current time.
sourceraw docstring

max-daysclj

(max-days auth-config)

The days auth-config lets a session last, however it is used.

The days `auth-config` lets a session last, however it is used.
sourceraw docstring

prepare-session-for-invalidationclj

(prepare-session-for-invalidation session current-time)

Pure function: Prepare session for invalidation.

Args: session: Current session entity current-time: Current timestamp

Returns: Session entity marked as revoked

Pure - data transformation only.

Pure function: Prepare session for invalidation.

Args:
  session: Current session entity
  current-time: Current timestamp
  
Returns:
  Session entity marked as revoked
  
Pure - data transformation only.
sourceraw docstring

prune-cutoffclj

(prune-cutoff now retention-days)

The instant before which an expired session may be deleted.

Retention is counted from expiry, not from creation: a session that expires today is removed retention-days from today, whatever its age. A retention of 0 deletes a session the moment it expires.

The instant before which an expired session may be deleted.

Retention is counted from expiry, not from creation: a session that expires
today is removed `retention-days` from today, whatever its age. A retention
of 0 deletes a session the moment it expires.
sourceraw docstring

reauth-pathclj

Where the page signs the user in again before the session ends (BOU-1007).

Where the page signs the user in again before the session ends (BOU-1007).
sourceraw docstring

same-ip?clj

(same-ip? a b)

Equal and known: two unresolved client addresses are not the same one.

Equal and known: two unresolved client addresses are not the same one.
sourceraw docstring

session-access-writeclj

(session-access-write session current-time max-days)

The session to write for an access at current-time, or nil when nothing needs writing: at most once a minute (BOU-666), so the expiry slides a minute late at most (BOU-1007).

The session to write for an access at `current-time`, or nil when nothing
needs writing: at most once a minute (BOU-666), so the expiry slides a
minute late at most (BOU-1007).
sourceraw docstring

should-cleanup-session?clj

(should-cleanup-session? session current-time cleanup-policy)

Return true if session has been expired longer than the grace period.

Return true if session has been expired longer than the grace period.
sourceraw docstring

should-require-additional-verification?clj

(should-require-additional-verification? session previous-sessions)

Return true if session risk score exceeds the verification threshold (0.5).

Return true if session risk score exceeds the verification threshold (0.5).
sourceraw docstring

update-session-accessclj

(update-session-access session current-time max-days)

session used at current-time: it slides by its own :duration-hours, the hours its sign-in got, never past ends-at (BOU-1007). One from before then has none and slides 24 hours, as it did.

`session` used at `current-time`: it slides by its own :duration-hours, the
hours its sign-in got, never past `ends-at` (BOU-1007). One from before
then has none and slides 24 hours, as it did.
sourceraw docstring

validate-session-creation-requestclj

(validate-session-creation-request session-data)

Validate that session-data has the required :user-id key.

Validate that session-data has the required :user-id key.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close