Skip to content

Commit

Permalink
feat(admin-ui): session viewer page
Browse files Browse the repository at this point in the history
  • Loading branch information
harryandriyan committed Aug 29, 2022
1 parent 9abc384 commit 4b8696e
Show file tree
Hide file tree
Showing 13 changed files with 377 additions and 0 deletions.
7 changes: 7 additions & 0 deletions admin-ui/app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"attributes": "Attributes",
"attribute_edit_type": "Attribute Edit Type",
"attribute_view_type": "Attribute View Type",
"auth_time": "Auth Time",
"authentication_method": "Authentication method for the Token Endpoint",
"authorization_code_access_token": "Authorization Code Access Token",
"average_of_mau": "Average of MAU",
Expand All @@ -69,6 +70,7 @@
"client_credentials_access_token": "Client Credentials Access Token",
"client_expiration_date": "Client Expiration Date",
"client_id": "Client Id",
"client_id_used": "Client Id Used",
"client_name": "Client name",
"client_secret": "Client secret",
"computation_pool_size": "Computation Pool Size",
Expand Down Expand Up @@ -112,6 +114,7 @@
"in_memory_configuration": "inMemoryConfiguration",
"internal": "Internal",
"introspection_scripts": "Introspection",
"ip_address": "IP Address",
"ropcScripts": "Password Grant",
"inum": "inum",
"is_active": "Active",
Expand Down Expand Up @@ -187,6 +190,8 @@
"sentinel_master_group_name": "sentinelMasterGroupName",
"servers": "Server Details",
"show_in_configuration_endpoint": "Show in configuration endpoint",
"s_id": "Session ID",
"session_expired": "Session Expired",
"smtp_server_port": "SMTP server port",
"smtp_test_status": "Smtp Test Status",
"smtp_user_name": "SMTP User Name",
Expand All @@ -201,6 +206,7 @@
"ssl_trust_store_file_path": "sslTrustStoreFilePath",
"ssl_trust_store_format": "SSL Trust Store Format",
"ssl_trust_store_pin": "SSL Trust Store Pin",
"state": "State",
"status": "Status",
"scopes": "Scopes",
"subject_type": "id_token subject type",
Expand Down Expand Up @@ -330,6 +336,7 @@
"scopes": "Scopes",
"scripts": "Scripts",
"services": "Services",
"sessions": "Sessions",
"settings": "Settings",
"signout": "Sign out",
"user_management": "User Management",
Expand Down
7 changes: 7 additions & 0 deletions admin-ui/app/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"scopes": "Portées",
"scripts": "Scénarios",
"services": "Prestations de service",
"sessions": "Séances",
"settings": "Paramètres",
"signout": "Déconnexion",
"user_management": "User Management",
Expand Down Expand Up @@ -91,6 +92,7 @@
"attributes": "Les attributs",
"attribute_edit_type": "Type de modification d'attribut",
"attribute_view_type": "Type de vue d'attribut",
"auth_time": "Heure d'authentification",
"authentication_method": "Méthode d'authentification pour le point de terminaison du jeton",
"authorization_code_access_token": "Jeton d'accès au code d'autorisation",
"average_of_mau": "Moyenne de MAU",
Expand All @@ -105,6 +107,7 @@
"client_credentials_access_token": "Jeton d'accès aux informations d'identification du client",
"client_expiration_date": "Date d'expiration du client",
"client_id": "Identité du client",
"client_id_used": "Identifiant client utilisé",
"client_name": "Nom du client",
"client_secret": "Secret du client",
"computation_pool_size": "Taille du pool de calcul",
Expand Down Expand Up @@ -146,6 +149,7 @@
"internal": "Interne",
"introspection_scripts": "Scripts d'introspection",
"inum": "inum",
"ip_address": "Adresse IP",
"is_active": "C'est actif",
"is_expirable_client": "est un client expirable ?",
"is_trusted_client": "Est un client de confiance",
Expand Down Expand Up @@ -210,6 +214,8 @@
"sentinel_master_group_name": "sentinelleMasterGroupName",
"servers": "Les serveurs",
"show_in_configuration_endpoint": "Afficher dans le point de terminaison de configuration",
"s_id": "ID de session",
"session_expired": "Session expirée",
"smtp_server_port": "Port du serveur SMTP",
"smtp_test_status": "État du test SMTP",
"smtp_user_name": "Nom d'utilisateur SMTP",
Expand All @@ -223,6 +229,7 @@
"ssl_trust_store_file_path": "sslTrustStoreFilePath",
"ssl_trust_store_format": "Format de magasin de confiance SSL",
"ssl_trust_store_pin": "NIP du magasin de confiance SSL",
"state": "État",
"status": "StatutStatut",
"subject_type": "Type de sujet",
"test_config": "Tester la configuration",
Expand Down
7 changes: 7 additions & 0 deletions admin-ui/app/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"scopes": "Scopes",
"scripts": "Scripts",
"services": "Serviços",
"sessions": "Sessão",
"settings": "Configurações",
"signout": "Sair",
"user_management": "User Management",
Expand Down Expand Up @@ -90,6 +91,7 @@
"attributes": "Atributos",
"attribute_edit_type": "Tipo de edição de atributo",
"attribute_view_type": "Tipo de visualização de atributo",
"auth_time": "Hora de autenticação",
"authentication_method": "Método de autenticação para o terminal de token",
"authorization_code_access_token": "Token de acesso ao código de autorização",
"average_of_mau": "Média de MAU",
Expand All @@ -104,6 +106,7 @@
"client_credentials_access_token": "Token de acesso de credenciais de cliente",
"client_expiration_date": "Data de Vencimento do Cliente",
"client_id": "ID do Cliente",
"client_id_used": "ID do cliente usado",
"client_name": "Nome do cliente",
"client_secret": "Segredo do cliente",
"computation_pool_size": "Tamanho do pool de computação",
Expand Down Expand Up @@ -145,6 +148,7 @@
"internal": "interno",
"introspection_scripts": "Scripts de introspecção",
"inum": "inum",
"ip_address": "Endereço de IP",
"is_active": "Está ativo",
"is_expirable_client": "É cliente expirável?",
"is_trusted_client": "É um cliente confiávelÉ um cliente confiável",
Expand Down Expand Up @@ -209,6 +213,8 @@
"sentinel_master_group_name": "sentinelMasterGroupName",
"servers": "Servidores",
"show_in_configuration_endpoint": "Mostrar ponto final na configuração",
"s_id": "ID da sessão",
"session_expired": "Sessão expirada",
"smtp_server_port": "Porta do servidor SMTP",
"smtp_test_status": "Status do teste Smtp",
"smtp_user_name": "Nome de usuário SMTP",
Expand All @@ -222,6 +228,7 @@
"ssl_trust_store_file_path": "sslTrustStoreFilePath",
"ssl_trust_store_format": "Formato SSL Trust Store",
"ssl_trust_store_pin": "Pin SSL Trust Store",
"state": "Estado",
"status": "Status",
"subject_type": "Tipo de Assunto",
"test_config": "Testar configuração",
Expand Down
1 change: 1 addition & 0 deletions admin-ui/plugins/auth-server/common/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export const FETCHING_SCOPES = 'Fetch scopes'
export const SEARCHING_SCRIPTS = 'Search scripts'
export const FETCHING_SCRIPTS = 'Fetch scripts'
export const FETCHING_JSON_PROPERTIES = 'Fetch json properties'
export const FETCHING_SESSIONS = 'Fetch session'

export const SIMPLE_PASSWORD_AUTH = 'simple_password_auth'
118 changes: 118 additions & 0 deletions admin-ui/plugins/auth-server/components/Sessions/SessionListPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React, { useState, useEffect, useContext } from 'react'
import MaterialTable from '@material-table/core'
import { DeleteOutlined } from '@material-ui/icons'
import { Paper } from '@material-ui/core'
import { connect } from 'react-redux'
import { Card, CardBody } from 'Components'
import GluuViewWrapper from 'Routes/Apps/Gluu/GluuViewWrapper'
import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
import { useTranslation } from 'react-i18next'
import { getSessions } from 'Plugins/auth-server/redux/actions/SessionActions'
import { buildPayload } from 'Utils/PermChecker'
import {
LIMIT,
PATTERN,
FETCHING_SESSIONS,
WITH_ASSOCIATED_CLIENTS,
} from 'Plugins/auth-server/common/Constants'
import SetTitle from 'Utils/SetTitle'
import { ThemeContext } from 'Context/theme/themeContext'
import getThemeColor from 'Context/theme/config'
import styles from './styles'

function SessionListPage({ sessions, loading, dispatch }) {
const { t } = useTranslation()
const userAction = {}
const options = {}
const myActions = []
const [item, setItem] = useState({})
const [modal, setModal] = useState(false)
const pageSize = localStorage.getItem('paggingSize') || 10
const [limit, setLimit] = useState(500)
const [pattern, setPattern] = useState(null)
const toggle = () => setModal(!modal)
const theme = useContext(ThemeContext)
const selectedTheme = theme.state.theme
const themeColors = getThemeColor(selectedTheme)
const bgThemeColor = { background: themeColors.background }

SetTitle(t('menus.sessions'))

const tableColumns = [
{ title: `${t('fields.s_id')}`, field: 'sid' },
{ title: `${t('fields.username')}`, field: 'auth_user' },
{ title: `${t('fields.ip_address')}`, field: 'remote_ip' },
{ title: `${t('fields.client_id_used')}`, field: 'client_id' },
{ title: `${t('fields.auth_time')}`, field: 'authenticationTime' },
{ title: `${t('fields.session_expired')}`, field: 'expirationDate' },
{ title: `${t('fields.state')}`, field: 'state' },
]

useEffect(() => {
makeOptions()
buildPayload(userAction, FETCHING_SESSIONS, options)
dispatch(getSessions(userAction))
}, [])

function makeOptions() {
setLimit(limit)
setPattern(pattern)
options[LIMIT] = limit
options[WITH_ASSOCIATED_CLIENTS] = true
if (pattern) {
options[PATTERN] = pattern
}
}

function handleRevoke(row) {
console.log('row', row)
}

myActions.push((rowData) => ({
icon: () => <DeleteOutlined />,
iconProps: {
color: 'secondary',
id: 'deleteScope' + rowData.inum,
},
tooltip: `${t('Delete Scope')}`,
onClick: (event, rowData) => handleRevoke(rowData),
disabled: false,
}))

return (
<Card style={applicationStyle.mainCard}>
<CardBody>
<GluuViewWrapper canShow>
<MaterialTable
components={{
Container: (props) => <Paper {...props} elevation={0} />,
}}
columns={tableColumns}
data={sessions}
isLoading={loading}
title=""
actions={myActions}
options={{
columnsButton: true,
search: true,
searchFieldAlignment: 'left',
selection: false,
pageSize: pageSize,
headerStyle: { ...applicationStyle.tableHeaderStyle, ...bgThemeColor },
actionsColumnIndex: -1,
}}
/>
</GluuViewWrapper>
</CardBody>
</Card>
)
}

const mapStateToProps = (state) => {
return {
sessions: state.sessionReducer.items,
loading: state.sessionReducer.loading,
permissions: state.authReducer.permissions,
}
}
export default connect(mapStateToProps)(SessionListPage)
11 changes: 11 additions & 0 deletions admin-ui/plugins/auth-server/components/Sessions/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { makeStyles } from '@material-ui/core/styles'

const styles = makeStyles(() => ({
link: {
color: '#1cb7ff',
textDecoration: 'underline',
fontWeight: 'bold'
},
}))

export default styles
16 changes: 16 additions & 0 deletions admin-ui/plugins/auth-server/plugin-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import ClientListPage from './components/Clients/ClientListPage'
import ClientAddPage from './components/Clients/ClientAddPage'
import ClientEditPage from './components/Clients/ClientEditPage'

import SessionListPage from './components/Sessions/SessionListPage'

import PropertiesPage from './components/Configuration/ConfigPage'
import KeysPage from './components/Configuration/Keys/KeysPage'
import LoggingPage from './components/Configuration/Defaults/LoggingPage'
Expand All @@ -19,6 +21,7 @@ import jwksReducer from './redux/reducers/JwksReducer'
import acrReducer from './redux/reducers/AcrReducer'
import loggingReducer from './redux/reducers/LoggingReducer'
import umaResourceReducer from './redux/reducers/UMAResourceReducer'
import sessionReducer from './redux/reducers/SessionReducer'

import scopesSaga from './redux/sagas/OAuthScopeSaga'
import oidcSaga from './redux/sagas/OIDCSaga'
Expand All @@ -27,6 +30,7 @@ import jwksSaga from './redux/sagas/JwksSaga'
import acrSaga from './redux/sagas/AcrsSaga'
import loggingSaga from './redux/sagas/LoggingSaga'
import umaResourceSaga from './redux/sagas/UMAResourceSaga'
import sessionSaga from './redux/sagas/SessionSaga'

import {
ACR_READ,
Expand All @@ -45,6 +49,11 @@ const pluginMetadata = {
title: 'menus.oauthserver',
icon: 'oauthserver',
children: [
{
title: 'menus.sessions',
path: PLUGIN_BASE_APTH + '/sessions',
permission: CLIENT_READ,
},
{
title: 'menus.configuration',
children: [
Expand Down Expand Up @@ -79,6 +88,11 @@ const pluginMetadata = {
},
],
routes: [
{
component: SessionListPage,
path: PLUGIN_BASE_APTH + '/sessions',
permission: CLIENT_READ,
},
{
component: ClientListPage,
path: PLUGIN_BASE_APTH + '/clients',
Expand Down Expand Up @@ -138,6 +152,7 @@ const pluginMetadata = {
{ name: 'acrReducer', reducer: acrReducer },
{ name: 'loggingReducer', reducer: loggingReducer },
{ name: 'umaResourceReducer', reducer: umaResourceReducer },
{ name: 'sessionReducer', reducer: sessionReducer },
],
sagas: [
scopesSaga(),
Expand All @@ -147,6 +162,7 @@ const pluginMetadata = {
acrSaga(),
loggingSaga(),
umaResourceSaga(),
sessionSaga()
],
}

Expand Down
32 changes: 32 additions & 0 deletions admin-ui/plugins/auth-server/redux/actions/SessionActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
GET_SESSIONS,
GET_SESSIONS_RESPONSE,
REVOKE_SESSION,
REVOKE_SESSION_RESPONSE,
RESET
} from './types'

export const getSessions = (action) => ({
type: GET_SESSIONS,
payload: { action },
})

export const getSessionsResponse = (data) => ({
type: GET_SESSIONS_RESPONSE,
payload: { data },
})

export const revokeSessions = (action) => ({
type: REVOKE_SESSION,
payload: { action },
})

export const revokeSessionsResponse = (data) => ({
type: REVOKE_SESSION_RESPONSE,
payload: { data },
})

export const resetSessions = () => ({
type: RESET,
payload: {},
})
6 changes: 6 additions & 0 deletions admin-ui/plugins/auth-server/redux/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ export const PUT_LOGGING_RESPONSE = 'PUT_LOGGING_RESPONSE'
// Health
export const GET_HEALTH = 'GET_HEALTH'
export const GET_HEALTH_RESPONSE = 'GET_HEALTH_RESPONSE'

// Session
export const GET_SESSIONS = 'GET_SESSIONS'
export const GET_SESSIONS_RESPONSE = 'GET_SESSIONS_RESPONSE'
export const REVOKE_SESSION = 'REVOKE_SESSION'
export const REVOKE_SESSION_RESPONSE = 'REVOKE_SESSION_RESPONSE'
Loading

0 comments on commit 4b8696e

Please sign in to comment.