Content-Length: 638877 | pFad | https://github.com/sebadob/rauthy/commit/41b4c9c19c061f36f3ed5fa97d75ddcf803e0614

E2 Merge pull request #110 from sebadob/ui-version-check · sebadob/rauthy@41b4c9c · GitHub
Skip to content

Commit

Permalink
Merge pull request #110 from sebadob/ui-version-check
Browse files Browse the repository at this point in the history
UI version check
  • Loading branch information
sebadob authored Oct 28, 2023
2 parents b338f26 + 7041587 commit 41b4c9c
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 57 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions frontend/src/components/AppVersion.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<script>
import {onMount} from "svelte";
import {getAppVersion} from "../utils/dataFetching.js";
let version = '';
let lastCheck;
let latestVersion;
let newVersionAvailable = false;
let updateUrl = '';
onMount(() => {
fetchVersion();
})
async function fetchVersion() {
let res = await getAppVersion();
if (res.ok) {
let body = await res.json();
version = body.current;
lastCheck = body.last_check;
latestVersion = body.latest;
updateUrl = body.latest_url;
newVersionAvailable = body.update_available;
}
}
</script>

{#if newVersionAvailable}
<div class="ver upd">
<a href={updateUrl} target="_blank">
v{version}⚠️
</a>
</div>
{:else}
<div class="ver">
v{version}
</div>
{/if}

<style>
.upd {
cursor: pointer;
}
.ver {
margin: 0 .25rem;
display: flex;
align-items: center;
font-size: .85rem;
}
.ver > a {
text-decoration: none;
color: var(--col-text);
}
</style>
90 changes: 55 additions & 35 deletions frontend/src/lib/nav/Nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import {tweened} from "svelte/motion";
import {cubicOut} from "svelte/easing";
import {onMount} from "svelte";
import AppVersion from "../../components/AppVersion.svelte";
export let selected = '';
export let widthExpanded = 180;
Expand Down Expand Up @@ -56,48 +57,60 @@
style:width="{$width}px"
style:padding={isExpanded ? '20px 10px' : '10px 3px'}
>
{#if isExpanded}
<div
role="button"
tabindex="0"
class="close"
style:left="calc({$width}px - 22px)"
in:fade|global={{ delay: 500, duration: 200 }}
out:fade|global={{ duration: 100 }}
on:click={toggle}
on:keypress={toggle}
>
<IconClose/>
<div>
{#if isExpanded}
<div
role="button"
tabindex="0"
class="close"
style:left="calc({$width}px - 22px)"
in:fade={{ delay: 500, duration: 200 }}
out:fade={{ duration: 100 }}
on:click={toggle}
on:keypress={toggle}
>
<IconClose/>
</div>

<div class="logo" in:fade={{ delay: 250, duration: 100 }} out:fade={{ duration: 20 }}>
<slot name="logo"></slot>
</div>
{:else}
<div
role="button"
tabindex="0"
class="burger"
style:left="3px"
in:fade={{ delay: 500, duration: 200 }}
out:fade={{ duration: 100 }}
on:click={toggle}
on:keypress={toggle}
>
<IconBurger width={24}/>
</div>
<div style:height="10px"></div>
<div class="logo" in:fade={{ delay: 250, duration: 100 }} out:fade={{ duration: 20 }}>
<slot name="logo"></slot>
</div>
{/if}

<div class="menu">
<div class="links">
<slot name="entries"></slot>
</div>
</div>
</div>

<div class="logo" in:fade|global={{ delay: 250, duration: 100 }} out:fade|global={{ duration: 20 }}>
<slot name="logo"></slot>
</div>
{:else}
{#if isExpanded}
<div
role="button"
tabindex="0"
class="burger"
style:left="3px"
in:fade|global={{ delay: 500, duration: 200 }}
out:fade|global={{ duration: 100 }}
on:click={toggle}
on:keypress={toggle}
class="version"
in:fade={{ delay: 500, duration: 200 }}
out:fade={{ duration: 100 }}
>
<IconBurger width={24}/>
</div>
<div style:height="10px"></div>
<div class="logo" in:fade|global={{ delay: 250, duration: 100 }} out:fade|global={{ duration: 20 }}>
<slot name="logo"></slot>
<AppVersion />
</div>
{/if}

<div class="menu">
<div class="links">
<slot name="entries"></slot>
</div>
</div>

</nav>

<style>
Expand Down Expand Up @@ -134,5 +147,12 @@
height: 100vh;
border-right: 1px solid var(--col-gmid);
box-shadow: 1px 0 5px var(--col-gmid);
display: flex;
flex-direction: column;
justify-content: space-between;
}
.version {
margin: 0 0 -15px -5px;
}
</style>
11 changes: 11 additions & 0 deletions frontend/src/routes/index/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import BrowserCheck from "../../components/BrowserCheck.svelte";
import WithI18n from "$lib/WithI18n.svelte";
import LangSelector from "$lib/LangSelector.svelte";
import AppVersion from "../../components/AppVersion.svelte";
const btnWidth = "9rem";
Expand Down Expand Up @@ -44,6 +45,10 @@
<Button on:click={redirectToAdmin} width={btnWidth}>{t.adminLogin.toUpperCase()}</Button>
</div>
<LangSelector absolute />

<div class="version">
<AppVersion />
</div>
</WithI18n>
</BrowserCheck>

Expand All @@ -52,4 +57,10 @@
display: flex;
flex-direction: column;
}
.version {
position: absolute;
bottom: 0;
right: 0;
}
</style>
8 changes: 8 additions & 0 deletions frontend/src/utils/dataFetching.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ export async function authorizeRefresh(data) {
return res;
}


export async function getAppVersion() {
return await fetch('/auth/v1/version', {
method: 'GET',
headers: HEADERS.json,
});
}

export async function checkAdminAccess() {
return await fetch('/auth/v1/auth_check_admin', {
method: 'GET',
Expand Down
1 change: 1 addition & 0 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const config = {
'/auth/v1/scopes': 'http://127.0.0.1:8080',
'/auth/v1/sessions': 'http://127.0.0.1:8080',
'/auth/v1/update_language': 'http://127.0.0.1:8080',
'/auth/v1/version': 'http://127.0.0.1:8080',
'/docs/v1/': 'http://127.0.0.1:8080',
}
}
Expand Down
1 change: 1 addition & 0 deletions rauthy-handlers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ rauthy-models = { path = "../rauthy-models" }
rauthy-service = { path = "../rauthy-service" }
redhac = { workspace = true }
rust-embed = { version = "6.8", features = ["actix-web", "tokio"] }
semver = { workspace = true }
time = { workspace = true }
tracing = { workspace = true }
tokio = { workspace = true }
Expand Down
47 changes: 45 additions & 2 deletions rauthy-handlers/src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ use actix_web::http::{header, StatusCode};
use actix_web::web::Json;
use actix_web::{get, post, put, web, HttpRequest, HttpResponse, Responder};
use rauthy_common::constants::{
APPLICATION_JSON, CACHE_NAME_LOGIN_DELAY, HEADER_HTML, IDX_LOGIN_TIME,
APPLICATION_JSON, CACHE_NAME_LOGIN_DELAY, HEADER_HTML, IDX_LOGIN_TIME, RAUTHY_VERSION,
};
use rauthy_common::error_response::ErrorResponse;
use rauthy_common::utils::build_csp_header;
use rauthy_models::app_state::AppState;
use rauthy_models::entity::api_keys::{AccessGroup, AccessRights};
use rauthy_models::entity::app_version::LatestAppVersion;
use rauthy_models::entity::colors::ColorEntity;
use rauthy_models::entity::is_db_alive;
use rauthy_models::entity::password::{PasswordHashTimes, PasswordPolicy};
Expand All @@ -30,7 +31,7 @@ use rauthy_models::request::{
EncKeyMigrateRequest, I18nContent, I18nRequest, PasswordHashTimesRequest, PasswordPolicyRequest,
};
use rauthy_models::response::{
Argon2ParamsResponse, EncKeysResponse, HealthResponse, LoginTimeResponse,
AppVersionResponse, Argon2ParamsResponse, EncKeysResponse, HealthResponse, LoginTimeResponse,
PasswordPolicyResponse,
};
use rauthy_models::templates::{
Expand All @@ -40,7 +41,10 @@ use rauthy_models::templates::{
};
use rauthy_service::encryption;
use redhac::{cache_get, cache_get_from, cache_get_value, QuorumHealth, QuorumState};
use semver::Version;
use std::borrow::Cow;
use std::str::FromStr;
use tracing::error;

#[get("/")]
pub async fn get_index(
Expand Down Expand Up @@ -679,3 +683,42 @@ pub async fn whoami(req: HttpRequest) -> impl Responder {
});
HttpResponse::Ok().body(resp)
}

//github.com/ Returns the current Rauthy Version
#[utoipa::path(
get,
path = "/version",
tag = "generic",
responses(
(status = 200, description = "Ok"),
),
)]
#[get("/version")]
pub async fn get_version(data: web::Data<AppState>) -> Result<HttpResponse, ErrorResponse> {
let resp = match LatestAppVersion::find(&data).await {
Some(latest) => {
let update_available = match Version::from_str(RAUTHY_VERSION) {
Ok(current) => latest.latest_version > current,
Err(err) => {
error!("Cannot parse RAUTHY_VERSION: {:?}", err);
false
}
};
AppVersionResponse {
current: RAUTHY_VERSION.to_string(),
last_check: Some(latest.timestamp),
latest: Some(latest.latest_version.to_string()),
latest_url: Some(latest.release_url.to_string()),
update_available,
}
}
None => AppVersionResponse {
current: RAUTHY_VERSION.to_string(),
last_check: None,
latest: None,
latest_url: None,
update_available: false,
},
};
Ok(HttpResponse::Ok().json(resp))
}
2 changes: 2 additions & 0 deletions rauthy-handlers/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use utoipa::{openapi, OpenApi};
generic::get_ready,
generic::ping,
generic::whoami,
generic::get_version,
groups::get_groups,
groups::post_group,
Expand Down Expand Up @@ -176,6 +177,7 @@ use utoipa::{openapi, OpenApi};
request::WebauthnAuthStartRequest,
request::WebauthnAuthFinishRequest,
response::AppVersionResponse,
response::BlacklistResponse,
response::BlacklistedIp,
response::LoginTimeResponse,
Expand Down
1 change: 1 addition & 0 deletions rauthy-main/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ async fn actix_main(app_state: web::Data<AppState>) -> std::io::Result<()> {
.service(generic::get_auth_check_admin)
.service(generic::post_i18n)
.service(generic::post_update_language)
.service(generic::get_version)
.service(oidc::get_authorize)
.service(oidc::post_authorize)
.service(oidc::get_callback_html)
Expand Down
Loading

0 comments on commit 41b4c9c

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/sebadob/rauthy/commit/41b4c9c19c061f36f3ed5fa97d75ddcf803e0614

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy