mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-25 08:12:19 +01:00
Authentication refresh
This commit is contained in:
+21
-21
@@ -19,40 +19,40 @@
|
||||
"dependencies": {
|
||||
"file-saver": "2.0.5",
|
||||
"notistack": "3.0.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react-tagsinput": "3.20.3",
|
||||
"rxjs": "7.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
|
||||
"@babel/runtime": "7.23.2",
|
||||
"@babel/runtime": "7.26.0",
|
||||
"@types/file-saver": "2.0.7",
|
||||
"@types/react": "18.2.37",
|
||||
"@types/react-dom": "18.2.15",
|
||||
"@types/react-tagsinput": "^3.20.4",
|
||||
"@types/video.js": "7.3.56",
|
||||
"@typescript-eslint/eslint-plugin": "6.11.0",
|
||||
"@typescript-eslint/parser": "6.11.0",
|
||||
"@types/react": "18.3.12",
|
||||
"@types/react-dom": "18.3.1",
|
||||
"@types/react-tagsinput": "3.20.6",
|
||||
"@types/video.js": "7.3.58",
|
||||
"@typescript-eslint/eslint-plugin": "8.15.0",
|
||||
"@typescript-eslint/parser": "8.15.0",
|
||||
"babel-eslint": "10.1.0",
|
||||
"concurrently": "8.2.2",
|
||||
"concurrently": "9.1.0",
|
||||
"cross-env": "7.0.3",
|
||||
"eslint": "8.53.0",
|
||||
"eslint-config-prettier": "9.0.0",
|
||||
"eslint": "9.15.0",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-config-react-app": "7.0.1",
|
||||
"eslint-plugin-flowtype": "8.0.3",
|
||||
"eslint-plugin-import": "2.29.0",
|
||||
"eslint-plugin-jest": "27.6.0",
|
||||
"eslint-plugin-jsx-a11y": "6.8.0",
|
||||
"eslint-plugin-import": "2.31.0",
|
||||
"eslint-plugin-jest": "28.9.0",
|
||||
"eslint-plugin-jsx-a11y": "6.10.2",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-react": "7.33.2",
|
||||
"eslint-plugin-react-hooks": "4.6.0",
|
||||
"prettier": "3.1.0",
|
||||
"eslint-plugin-react": "7.37.2",
|
||||
"eslint-plugin-react-hooks": "5.0.0",
|
||||
"prettier": "3.3.3",
|
||||
"react-scripts": "5.0.1",
|
||||
"sass": "1.69.5",
|
||||
"sass": "1.81.0",
|
||||
"source-map-explorer": "2.5.3",
|
||||
"typescript": "5.2.2",
|
||||
"wait-on": "7.2.0"
|
||||
"typescript": "5.6.3",
|
||||
"wait-on": "8.0.1"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
|
||||
@@ -17,7 +17,12 @@ export default function Authentication(): JSX.Element {
|
||||
error: () => setAuthenticated(false),
|
||||
})
|
||||
|
||||
services.auth().authenticate('test', 'test').pipe(tap(() => setLoading(false)), first()).subscribe(noop);
|
||||
const noAuthCheck = () => services.auth().authenticate('test', 'test').pipe(tap(() => setLoading(false)), first()).subscribe(noop);
|
||||
|
||||
services.auth().refresh().pipe(first()).subscribe({
|
||||
next: (authenticated) =>!authenticated && noAuthCheck(),
|
||||
error: () => noAuthCheck(),
|
||||
});
|
||||
|
||||
return () => sub.unsubscribe();
|
||||
}, [services]);
|
||||
|
||||
@@ -21,6 +21,9 @@ async fn token(
|
||||
match &app_state.config.web_auth {
|
||||
None => no_web_auth_token(),
|
||||
Some(web_auth) => {
|
||||
if !web_auth.enabled {
|
||||
return no_web_auth_token();
|
||||
}
|
||||
let username = req.username.as_str();
|
||||
let password = req.password.as_str();
|
||||
|
||||
@@ -50,6 +53,9 @@ async fn token_refresh(
|
||||
no_web_auth_token()
|
||||
},
|
||||
Some(web_auth) => {
|
||||
if !web_auth.enabled {
|
||||
return no_web_auth_token();
|
||||
}
|
||||
let secret_key = web_auth.secret.as_ref();
|
||||
if verify_token(credentials, secret_key) {
|
||||
if let Ok(token) = create_jwt(app_state.config.web_auth.as_ref().unwrap()) {
|
||||
|
||||
Reference in New Issue
Block a user