-
Notifications
You must be signed in to change notification settings - Fork 1
Implement React GUI #69
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
Draft
inbarbarkai
wants to merge
89
commits into
main
Choose a base branch
from
react
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
fb3e0c8
Added empty react project.
inbarbarkai c57693e
Implemented the login flow.
inbarbarkai 0176777
Automatically routing the user to index.
inbarbarkai 64b4b3a
Creating custom image of keycloak.
inbarbarkai 88121f2
Added app container.
inbarbarkai 718ae95
Needs the correct permissions (chmod +x)
e38f85f
added invitaions ui
KamiTzayig 10d5636
Some docker fixes and improvements
171ea36
Removed unused interface.
inbarbarkai fbf1dca
Added user model.
inbarbarkai d455065
Implemented a helper class to convert snake case to camel case.
inbarbarkai c75ca0d
Converted user dictionary to an object.
inbarbarkai a625037
Fixed authentication configuration.
inbarbarkai 573f43a
Added options to get the server base URL.
inbarbarkai f5a227c
Implemented service to get invitations.
inbarbarkai 591ea0a
Getting invitations.
inbarbarkai d8b5447
Using context to get the necessery services.
inbarbarkai 1330515
Fixed useEffect dependency argument.
inbarbarkai f265a7c
Implified root path.
inbarbarkai c6ca792
Converting json before casting.
inbarbarkai 18cb663
Fully implemented the inviter proxy class.
inbarbarkai b559d1d
Fixed rename.
inbarbarkai 81ca1c2
Converted models to interfaces.
inbarbarkai e75322e
Implemented helper method to convert an object to snake case.
inbarbarkai 81635d6
Using current user for creating an invitation.
inbarbarkai fc7288e
Fixed compile warnings.
inbarbarkai 25e3db5
Converting to snake_case before sending to server.
inbarbarkai b55566e
Renamed user to inviter.
inbarbarkai ffd5de8
Fixed casing.
inbarbarkai 15bb631
Updated packages.
inbarbarkai 75ec673
Implemented a view for creating a new invitation.
inbarbarkai e4de228
Converted to a form.
inbarbarkai b29b70a
Separated logic from view.
inbarbarkai af51f82
Fixed infinite loop.
inbarbarkai 2daa831
Fixed component name.
inbarbarkai 4b41445
Fixed update and create invitation requests.
inbarbarkai fec5e93
Implemented feature for updating an invitation.
inbarbarkai d267ea0
Implemented handling of unauthorized response.
inbarbarkai 9190dcc
Allowing to pass a return url via the session state.
inbarbarkai db69e30
Implemented placeholders for admin and guard functionality.
inbarbarkai c1ef7a0
fix: web/Dockerfile to reduce vulnerabilities (#76)
snyk-bot 43a7532
fixed some lint issues
KamiTzayig 4f71b1c
working on a solution for create invitation error
KamiTzayig f924299
fixed useApplicationContext error
KamiTzayig 6746c45
improved invitation screen ui
KamiTzayig f661a0d
improving ui, and adding "my invitations"
KamiTzayig d237027
improvment of invitaion form ui
KamiTzayig a229478
Simplified invitations form implementation.
inbarbarkai 69b76ea
Fixed form implementation.
inbarbarkai edb5f1a
Formatted the code.
inbarbarkai 7c02fda
Fixed conversion method.
inbarbarkai 7b500a2
Converting object to string.
inbarbarkai c62e516
Using generic get method.
inbarbarkai 8ee0108
Fixed authentication handling.
inbarbarkai 93fde23
Getting the proxy before calling useEffect.
inbarbarkai 8521c5d
Fixed fetch method.
inbarbarkai 1b42c35
Moved rendering of a row to a separate method.
inbarbarkai 358a5ef
Removed unnecessery alert.
inbarbarkai 1341692
Removed mock data.
inbarbarkai 99e3717
Added invite route
inbarbarkai 79b5aa5
Removed unnecessery script argument.
inbarbarkai ad34981
Restored original configuration.
inbarbarkai e045e08
Fixed linter errors.
inbarbarkai d67b1e4
starting to work on guard screen
KamiTzayig 675133f
added base table for guard screen
KamiTzayig 71b8a96
guard proxy
KamiTzayig abc4dfc
Added guard proxy to context.
inbarbarkai 8492d33
Implemented call to backend when changing admittance.
inbarbarkai 2eae348
Fixed getting the pending invitations.
inbarbarkai 5228244
Fixed getting users from keycloak.
inbarbarkai 60fff08
Filling the name of the user while displaying the invitation.
inbarbarkai f31e2d3
Moved logic to a store.
inbarbarkai 91ebd0c
Updated react packages.
inbarbarkai 1c11df9
Fixed linter errors.
inbarbarkai 47dbada
Removed unused imports.
inbarbarkai 7524a2b
Extracted logo to an external component.
inbarbarkai 48a1a88
Implemented links to invitations.
inbarbarkai b0f884b
Added routing for guard.
inbarbarkai 04dbf1e
Implemented method to parse a JWT token.
inbarbarkai ce871f0
Implemented method to get the user roles.
inbarbarkai ebfbd31
Implemented a unified navigation bar.
inbarbarkai a4181bd
using the new navigation bar.
inbarbarkai e8aad4c
Removed the individual navigation bars.
inbarbarkai 363f2c5
Updated keycloak seed
inbarbarkai 81ea683
Updated packages
inbarbarkai c1e6d00
fix: web/Dockerfile to reduce vulnerabilities (#90)
snyk-bot 968df40
Update Dockerfile
yarons e1e3791
fix: web/Dockerfile to reduce vulnerabilities (#91)
yarons 3d7ef07
fix: web/Dockerfile to reduce vulnerabilities (#92)
yarons 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 hidden or 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 |
|---|---|---|
|
|
@@ -127,3 +127,5 @@ dmypy.json | |
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
| node_modules/ | ||
| package-lock.json | ||
This file contains hidden or 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 hidden or 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,4 @@ | ||
| FROM jboss/keycloak:latest | ||
|
|
||
| ADD kc-seed.sh /opt/jboss/startup-scripts/kc-seed.sh | ||
| ADD standalone.xml /opt/jboss/keycloak/standalone/configuration/standalone.xml |
0
init/keycloak/kc-seed.sh → keycloak/kc-seed.sh
100755 → 100644
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,17 @@ | ||
| FROM node:18-bullseye-slim as builder | ||
|
|
||
| RUN mkdir /source | ||
|
|
||
| WORKDIR /source | ||
|
|
||
| ADD src/ /source/src | ||
| ADD public/ /source/public | ||
| ADD package.json tsconfig.json /source/ | ||
|
|
||
| RUN npm install \ | ||
| && npm run build | ||
|
|
||
| FROM nginx:1.21.6-alpine | ||
|
|
||
| ADD nginx.conf /etc/nginx/nginx.conf | ||
| COPY --from=builder /source/build /var/www/ |
This file contains hidden or 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,19 @@ | ||
| worker_processes 5; ## Default: 1 | ||
|
|
||
| events { | ||
| worker_connections 4096; ## Default: 1024 | ||
| } | ||
|
|
||
| http { | ||
| server { | ||
| listen 80; | ||
| listen [::]:80; | ||
|
|
||
| root /var/www/; | ||
| index index.html index.htm; | ||
|
|
||
| location / { | ||
| try_files $uri $uri/ /index.html; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,37 @@ | ||
| { | ||
| "name": "invitease", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "dependencies": { | ||
| "oidc-client-ts": "^2.0.3", | ||
| "react": "^18.0.0", | ||
| "react-dom": "^18.0.0", | ||
| "react-router-dom": "^6.3.0", | ||
| "react-scripts": "^5.0.0" | ||
| }, | ||
| "scripts": { | ||
| "start": "react-scripts --max_old_space_size=8128 start", | ||
| "build": "react-scripts build", | ||
| "test": "react-scripts test", | ||
| "eject": "react-scripts eject" | ||
| }, | ||
| "eslintConfig": { | ||
| "extends": "react-app" | ||
| }, | ||
| "browserslist": { | ||
| "production": [ | ||
| ">0.2%", | ||
| "not dead", | ||
| "not op_mini all" | ||
| ], | ||
| "development": [ | ||
| "last 1 chrome version", | ||
| "last 1 firefox version", | ||
| "last 1 safari version" | ||
| ] | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^18.0.6", | ||
| "@types/react-dom": "^18.0.2" | ||
| } | ||
| } |
This file contains hidden or 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,9 @@ | ||
| config = { | ||
| 'serverUrl': 'http://invitease.localhost/', | ||
| 'applicationRoot':'http://localhost:3000/', | ||
| 'authentication': { | ||
| 'clientId': 'invitease', | ||
| 'serviceUrl': 'http://keycloak.localhost/auth/realms/master/', | ||
| 'scope': 'openid profile email phone' | ||
| } | ||
| } |
This file contains hidden or 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,13 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <script src="./config.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <noscript>You need to enable JavaScript to run this app.</noscript> | ||
| <div id="root"></div> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or 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,19 @@ | ||
| import * as React from 'react'; | ||
| import { Routes, Route, Navigate } from "react-router-dom"; | ||
| import Example from './components/example'; | ||
| import SecureRoute from './components/secureRoute'; | ||
| import { SigninCallback } from "./components/signinCallback"; | ||
|
|
||
| function App() { | ||
|
|
||
| return ( | ||
| <Routes> | ||
| <Route path='/' element={<Navigate to='index' />}> | ||
| </Route> | ||
| <Route path="signin-callback" element={<SigninCallback />} /> | ||
| <Route path='index' element={<SecureRoute><Example /></SecureRoute>} /> | ||
| </Routes> | ||
| ); | ||
| } | ||
|
|
||
| export default App; |
This file contains hidden or 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,20 @@ | ||
| import * as React from 'react'; | ||
| import { useState } from 'react'; | ||
| import { User } from 'oidc-client-ts'; | ||
| import { AuthenticationService } from '../services/authenticationService'; | ||
| import { SettingsService } from '../services/settingsService'; | ||
|
|
||
| export default function Example() { | ||
| let authSettings = new SettingsService().getAuthenticationSettings(); | ||
| let authService = new AuthenticationService(authSettings); | ||
| const [user, setUser] = useState<User | undefined>(); | ||
| React.useEffect(() => { | ||
| if (!user) { | ||
| authService.getUser() | ||
| .then(user => setUser(user)); | ||
| } | ||
| }, [user]); | ||
| return (<pre> | ||
| {JSON.stringify(user, null, 2)} | ||
| </pre>); | ||
| } |
This file contains hidden or 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,17 @@ | ||
| import * as React from 'react'; | ||
| import { useEffect } from 'react'; | ||
| import { AuthenticationService } from '../services/authenticationService'; | ||
| import { SettingsService } from '../services/settingsService'; | ||
|
|
||
| export default function SecureRoute(props: any) { | ||
| let authSettings = new SettingsService().getAuthenticationSettings(); | ||
| let authService = new AuthenticationService(authSettings); | ||
| useEffect(() => { | ||
| authService.getUser().then(user => { | ||
| if (!user) { | ||
| authService.login(); | ||
| } | ||
| }); | ||
| }); | ||
| return (<>{props.children}</>); | ||
| } |
This file contains hidden or 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,13 @@ | ||
| import * as React from 'react'; | ||
| import { AuthenticationService } from '../services/authenticationService'; | ||
| import { SettingsService } from '../services/settingsService'; | ||
|
|
||
| export function SigninCallback() { | ||
| let authSettings = new SettingsService().getAuthenticationSettings(); | ||
| let authService = new AuthenticationService(authSettings); | ||
| React.useEffect(() => { | ||
| authService.handleSignin() | ||
| .then(user => (window as any).location.href = authSettings.applicationRoot + "index"); | ||
| }); | ||
| return (<></>); | ||
| } |
This file contains hidden or 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,13 @@ | ||
| import * as React from 'react'; | ||
| import * as ReactDOM from 'react-dom/client'; | ||
| import App from './app'; | ||
| import { BrowserRouter } from "react-router-dom"; | ||
|
|
||
| const root = ReactDOM.createRoot(document.getElementById('root')); | ||
| root.render( | ||
| <React.StrictMode> | ||
| <BrowserRouter> | ||
| <App /> | ||
| </BrowserRouter> | ||
| </React.StrictMode> | ||
| ); |
This file contains hidden or 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,40 @@ | ||
| import { Log, User, UserManager } from 'oidc-client-ts'; | ||
| import { AuthenticationSettings } from '../settings/AuthenticationSettings'; | ||
|
|
||
| export class AuthenticationService { | ||
| public userManager: UserManager; | ||
|
|
||
| constructor(settings: AuthenticationSettings) { | ||
| const oidcSettings = { | ||
| authority: settings.serviceUrl, | ||
| client_id: settings.clientId, | ||
| redirect_uri: settings.applicationRoot + `signin-callback`, | ||
yarons marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| response_type: 'code', | ||
| scope: settings.scope | ||
| }; | ||
| this.userManager = new UserManager(oidcSettings); | ||
|
|
||
| Log.setLogger(console); | ||
| Log.setLevel(Log.INFO); | ||
| } | ||
|
|
||
| public getUser(): Promise<User | null> { | ||
| return this.userManager.getUser(); | ||
| } | ||
|
|
||
| public login(): Promise<void> { | ||
| return this.userManager.signinRedirect(); | ||
| } | ||
|
|
||
| public renewToken(): Promise<User> { | ||
| return this.userManager.signinSilent(); | ||
| } | ||
|
|
||
| public logout(): Promise<void> { | ||
| return this.userManager.signoutRedirect(); | ||
| } | ||
|
|
||
| public async handleSignin(): Promise<void> { | ||
| await this.userManager.signinRedirectCallback(); | ||
| } | ||
| } | ||
This file contains hidden or 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,14 @@ | ||
| import { AuthenticationSettings } from '../settings/AuthenticationSettings'; | ||
|
|
||
| export class SettingsService { | ||
| public getAuthenticationSettings(): AuthenticationSettings { | ||
| let settings = new AuthenticationSettings(); | ||
|
|
||
| settings.clientId = (window as any).config.authentication.clientId; | ||
| settings.serviceUrl = (window as any).config.authentication.serviceUrl; | ||
| settings.scope = (window as any).config.authentication.clientScope; | ||
| settings.applicationRoot = (window as any).config.applicationRoot; | ||
|
|
||
| return settings; | ||
| } | ||
| } |
This file contains hidden or 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,6 @@ | ||
| export class AuthenticationSettings { | ||
| clientId: string | ||
| serviceUrl: string | ||
| scope: string | ||
| applicationRoot: string | ||
| } |
This file contains hidden or 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,16 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "noImplicitAny": true, | ||
| "removeComments": true, | ||
| "declaration": true, | ||
| "sourceMap": true, | ||
| "jsx": "react" | ||
| }, | ||
| "include": [ | ||
| "./src/**/*.tsx", | ||
| "./src/**/*.ts" | ||
| ], | ||
| "exclude": [ | ||
| "node_modules" | ||
| ] | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.