-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Openid #2945
Closed
Closed
[WIP] Openid #2945
Changes from all commits
Commits
Show all changes
160 commits
Select commit
Hold shift + click to select a range
e3a1cd6
OpenId implementation
apilat cb75f63
Fix bootstrap (doesn't include OpenID yet)
apilat 03acb3b
Add frontend for OpenID bootstrap
apilat 2e13fed
Address code review
apilat 28c323e
Fix typecheck and add release notes
apilat e3ed86a
Merge branch 'master' into openid
apilat 8696956
Changing the autocomplete search to accept text without accents to ma…
lelemm 29bd12f
lint fix
lelemm 0c35c91
Added upcoming-release-notes
lelemm 4fb4424
Release note authors should be a list.
lelemm a31861a
Release note file upcoming-release-notes/2842.md body should contain …
lelemm e4e37a5
smaller 2842.md
lelemm 850865b
Merge branch 'actualbudget:master' into master
lelemm 27aeb09
Merge branch 'actualbudget:master' into master
lelemm 914106e
Merge branch 'actualbudget:master' into master
lelemm b1d02bf
create schedules from csv import
lelemm 9e4f185
lint
lelemm 939b870
Merge pull request #1 from lelemm/DetectInstallments
lelemm a86b7a3
merge
lelemm f2344c0
Merge branch 'actualbudget:master' into master
lelemm 9031ede
Merge branch 'master' into openid
lelemm cf1b485
working example
lelemm 08a2d32
removed not related files from the original branch
lelemm 262a4ff
REMOVED UNRELATED CUSTOM
lelemm 8cbcc3f
old merge cleanup
lelemm d921631
Merge branch 'actualbudget:master' into openid
lelemm ee43263
added me to the md
lelemm e3118d8
Merge branch 'openid' of https://github.com/lelemm/actual into openid
lelemm 3213048
lint
lelemm 963f11c
cleanup
lelemm 403c73f
cleanup
lelemm 55ff88d
reverting
lelemm 919bc5b
typecheck
lelemm 5a7ef59
lint
lelemm db47c22
fixes on lint, typecheck and tests
lelemm 4beabb5
Merge branch 'master' into openid
lelemm 9b53173
lint after merge
lelemm e5feddd
moving to another pc
lelemm d56e1f2
Removing out of scope features
lelemm ad1d774
fixes and lint
lelemm 0aa1f74
features
lelemm eba7af7
more features
lelemm e5ea5b6
changed from isOpenId to multiuserEnabled
lelemm 637fa93
bug fixes and linter
lelemm 5214fce
Merge remote-tracking branch 'org/master' into openid
lelemm 899494a
merge fixes and linter
lelemm da7b0d6
Merge remote-tracking branch 'org/master' into openid
lelemm 8389cee
fix for Modal2
lelemm 6eb64df
merge fix
lelemm 7deb883
linter
lelemm e633c8c
fix to launch demo
lelemm db82dba
lint
lelemm 618202a
typecheck fixes
lelemm f8da704
lint
lelemm ccbabe5
changing error location
lelemm 04369bc
lint
lelemm 57dcb89
change ref
lelemm b6e7c48
ops, missing errors here
lelemm c7c1f4a
more typecheck fixes
lelemm e5ce252
typecheck and lint
lelemm 6522800
lint and typecheck, once again Oo
lelemm 4b72a00
Merge branch 'master' into openid
lelemm cd6c283
fix for visual regression
lelemm 0c67d72
now typecheck
lelemm 1d06652
why did I deleted this?
lelemm 1226f5b
type-o
lelemm c4f37c0
looprole
lelemm cc39152
looprole
lelemm 2c6d71d
deleted the file wrongly
lelemm 12ae11c
revert gitignore changes
lelemm 6a5e520
reverting the only test change
lelemm c4995f7
fixes
lelemm 2d80c1d
fixes
lelemm 1e04f3a
Merge branch 'openid' of https://github.com/lelemm/actual into openid
lelemm 9a9aeb8
typecheck and test fixes
lelemm 7cc9c30
lint fix
lelemm e8cfa79
added authentication method to visual regression
lelemm bd66917
change location of component
lelemm 46301c4
lint again
lelemm 187e841
fixes and QOL improvements
lelemm e76d74c
fix
lelemm 7a77f86
redirect on login was not working
lelemm 20e8864
fix on login layout
lelemm 1c4e858
QOL changes
lelemm d3b9659
more fixes
lelemm e7ae31c
fixes
lelemm 3893b22
missing condition
lelemm de9664c
more providers
lelemm 9cec67c
linter
lelemm a134bdc
added keycloak
lelemm 9d70014
typecheck
lelemm 25e4694
more typecheck
lelemm 2ad5123
typecheck
lelemm 2dffea4
linter
lelemm 0bfc25a
typecheck again
lelemm fc87021
added Authentik
lelemm 817c3a6
Merge branch 'master' into openid
lelemm 0048608
Merge branch 'master' into openid
lelemm b2ab60a
Merge branch 'master' into openid
lelemm 622b195
typecheck and lint
lelemm 7b14b89
Merge branch 'master' into openid
lelemm 7f405b1
Merge branch 'master' into openid
lelemm 6ce0a93
merge fixes
lelemm 7f10bf2
more merge fixes
lelemm 55246f9
linter
lelemm cabf174
Merge branch 'master' into openid
lelemm b2fd2e2
linter
lelemm 780a3d6
Merge branch 'openid' of https://github.com/lelemm/actual into openid
lelemm 75db9a4
Merge branch 'master' into openid
lelemm ce5ee9b
fixes
lelemm ea1b56f
linter
lelemm 6a78649
fixes
lelemm 29b87ab
linter
lelemm 8d4745a
linter and typecheck
lelemm 8056d43
PR review suggestion
lelemm 2b20ba1
code review fixes
lelemm e7c6d79
linter + typecheck
lelemm d2b8dd6
master user -> server owner
lelemm 12af985
change to link to types of permissions
lelemm f4cd173
removed debugger
lelemm 25687b2
changes based on feedback
lelemm c81841f
typecheck
lelemm c6f66c5
typecheck
lelemm ffbfd97
vrt
lelemm 3f4b287
linter
lelemm 521b8d2
Merge branch 'master' into openid
lelemm 7cb7918
vrt
lelemm 925337f
Merge branch 'openid' of https://github.com/lelemm/actual into openid
lelemm 9de7cc0
Merge branch 'master' into openid
lelemm a057f68
vrt
lelemm 01b1273
vrt
lelemm c37c74d
code review suggestion
lelemm e5025ca
Merge remote-tracking branch 'org/master' into openid
lelemm d2ec0c2
typecheck and linter
lelemm ff992ab
wrong file
lelemm 9c88bc1
Merge remote-tracking branch 'org/master' into openid_rescue
lelemm 59ac6ee
fixes on merge
lelemm ce1b8b7
Merge branch 'openid' of https://github.com/lelemm/actual into openid
lelemm 76c3fac
linter + typecheck
lelemm 226282e
Update packages/desktop-client/src/components/common/Button2.tsx
lelemm 4750516
Update packages/desktop-client/src/components/LoggedInUser.tsx
lelemm ddfe646
Update packages/desktop-client/src/components/admin/UserAccess/UserAc…
lelemm bfc4b5d
ai code review suggestions
lelemm f789f30
Merge branch 'openid' of https://github.com/lelemm/actual into openid
lelemm 2c13abc
refactors
lelemm 5a23f3f
fixes
lelemm 4d522e5
changed masterCreated to ownerCreated
lelemm 6626f83
changed routes
lelemm 051b29a
WPA adjustment
lelemm 6553314
WPA adjustment
lelemm 5cb9613
fixes
lelemm 97ebff9
fixes and refactories based on actual-server changes
lelemm 43b49e2
more code review
lelemm 7bdff09
linter
lelemm 4453145
trigger actions
lelemm 3ec6cc1
fixes and code enhancement
lelemm 906ed5e
Merge remote-tracking branch 'org/master' into openid
lelemm d4b0e49
merge fixes
lelemm 30afb0e
fixes after actual-server reviews and fixes from merge
lelemm ae2506f
fix
lelemm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+1.53 KB
(100%)
...ettings.test.js-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.51 KB
(100%)
...ettings.test.js-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { createContext, useContext, type ReactNode } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { type State } from 'loot-core/client/state-types'; | ||
|
||
import { type Permissions } from './types'; | ||
|
||
type AuthContextType = { | ||
hasPermission: (permission?: Permissions) => boolean; | ||
}; | ||
|
||
const AuthContext = createContext<AuthContextType | undefined>(undefined); | ||
|
||
type AuthProviderProps = { | ||
children?: ReactNode; | ||
}; | ||
|
||
export const AuthProvider = ({ children }: AuthProviderProps) => { | ||
const userData = useSelector((state: State) => state.user.data); | ||
|
||
const hasPermission = (permission?: Permissions) => { | ||
if (!permission) { | ||
return true; | ||
} | ||
|
||
return ( | ||
(userData?.offline ?? false) || | ||
userData?.permission?.toUpperCase() === permission?.toUpperCase() | ||
); | ||
}; | ||
|
||
return ( | ||
<AuthContext.Provider value={{ hasPermission }}> | ||
{children} | ||
</AuthContext.Provider> | ||
); | ||
}; | ||
|
||
export const useAuth = () => { | ||
const context = useContext(AuthContext); | ||
if (context === undefined) { | ||
throw new Error('useAuth must be used within an AuthProvider'); | ||
} | ||
return context; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useEffect, useState, type ReactElement } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { type RemoteFile, type SyncedLocalFile } from 'loot-core/types/file'; | ||
|
||
import { View } from '../components/common/View'; | ||
import { useMetadataPref } from '../hooks/useMetadataPref'; | ||
|
||
import { useAuth } from './AuthProvider'; | ||
import { type Permissions } from './types'; | ||
|
||
type ProtectedRouteProps = { | ||
permission: Permissions; | ||
element: ReactElement; | ||
validateOwner?: boolean; | ||
}; | ||
|
||
export const ProtectedRoute = ({ | ||
element, | ||
permission, | ||
validateOwner, | ||
}: ProtectedRouteProps) => { | ||
const { hasPermission } = useAuth(); | ||
const [permissionGranted, setPermissionGranted] = useState(false); | ||
const [cloudFileId] = useMetadataPref('cloudFileId'); | ||
const allFiles = useSelector(state => state.budgets.allFiles || []); | ||
const remoteFiles = allFiles.filter( | ||
f => f.state === 'remote' || f.state === 'synced' || f.state === 'detached', | ||
) as (SyncedLocalFile | RemoteFile)[]; | ||
const currentFile = remoteFiles.find(f => f.cloudFileId === cloudFileId); | ||
const userData = useSelector(state => state.user.data); | ||
|
||
useEffect(() => { | ||
const hasRequiredPermission = hasPermission(permission); | ||
setPermissionGranted(hasRequiredPermission); | ||
|
||
if (!hasRequiredPermission && validateOwner) { | ||
if (currentFile) { | ||
setPermissionGranted( | ||
currentFile.usersWithAccess.some(u => u.userId === userData?.userId), | ||
); | ||
} | ||
} | ||
}, [ | ||
cloudFileId, | ||
permission, | ||
validateOwner, | ||
hasPermission, | ||
currentFile, | ||
userData, | ||
]); | ||
|
||
return permissionGranted ? ( | ||
element | ||
) : ( | ||
<View | ||
style={{ | ||
margin: '50px', | ||
}} | ||
> | ||
<h3>You don't have permission to view this page</h3> | ||
</View> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum Permissions { | ||
ADMINISTRATOR = 'ADMIN', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate
useEffect
hooks to eliminate redundancyThe
useEffect
hooks starting at lines 117 and 135 are identical, resulting in redundant execution of the same code. This can lead to unintended side effects, such as multiple notifications for a single token expiration event. Please remove one of the duplicateuseEffect
blocks to avoid redundancy.Apply this diff to remove the duplicate
useEffect
hook:Also applies to: 135-151