Skip to content
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

Implementado suporte a usuários do SPED #37

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,39 @@ Para mais informações acessar a [Wiki](https://github.com/1cgeo/auth_server/wi
## Releases
- [v.1.1.0](https://github.com/1cgeo/auth_server/releases/tag/v.1.1.0)
- [v.1.0.0](https://github.com/1cgeo/auth_server/releases/tag/v.1.0.0)

## Requisitos para sincronização com serviço LDAP local (existente no SPED).

1. Certifique-se que o serviço LDAP do SPED está aberto para a serviço de autenticação:
Executar no computador do serviço LDAP:
```
$ nano /etc/default/slapd # Editar:
#SLAPD_SERVICES="ldap://127.0.0.1:389/ ldaps:/// ldapi:///"
SLAPD_SERVICES="ldap://<IP_SERVIÇO_AUTENTICAÇÃO>/ ldapi://<IP_SERVIÇO_AUTENTICAÇÃO>/"

$ service slapd restart
```

Executar no computador do serviço de autenticação:
```
$ apt install ldap-utils
$ ldapsearch -H ldap://<IP_LDAP> -x -b dc=eb,dc=mil,dc=br # deve retornar até 500 usuários
```

2. Autorizar a pesquisa de mais de 500 usuários:
Executar no computador do serviço LDAP:
```
$ nano sizelimit.ldif # Adicionar o seguinte conteúdo
dn: cn=config
changetype: modify
replace: olcSizeLimit
olcSizeLimit: 7000

$ ldapmodify -Q -Y EXTERNAL -H ldapi:// -f sizelimit.ldif
```

Executar no computador do serviço de autenticação:
```
$ apt install ldap-utils
$ ldapsearch -H ldap://<IP_LDAP> -x -b dc=eb,dc=mil,dc=br # deve retornar até 7000 usuários
```
34 changes: 28 additions & 6 deletions client/package-lock.json

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

74 changes: 73 additions & 1 deletion client/src/contexts/apiContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,74 @@ export default function APIProvider({ children }) {
}
}

const getLDAPUsers = async (
basedn,
ldapurl,
) => {
const response = await callAxios(
`/api/usuarios/getldapusers`,
"POST",
{
basedn: basedn,
ldapurl: ldapurl,
}
);
if (response.error) {
handleError(response.error)
return
}
return response.data
}

const saveLDAPenv = async (
basedn,
ldapurl,
) => {
const response = await callAxios(
`/api/usuarios/saveldapenv`,
"POST",
{
basedn: basedn,
ldapurl: ldapurl,
}
);
if (response.error) {
handleError(response.error)
return
}
return response.data
}

const getLDAPenv = async () => {
const response = await callAxios(
`/api/usuarios/getldapenv`,
"GET",
{}
);
if (response.error) {
handleError(response.error)
return
}
return response.data
}

const upsertLDAPuser = async (usuario, nome, nomeGuerra) => {
const response = await callAxios(
`/api/usuarios/upsertldapuser`,
"POST",
{
usuario: usuario,
nome: nome,
nomeGuerra: nomeGuerra,
}
);
if (response.error) {
handleError(response.error)
return
}
return response.data
}

return (
<APIContext.Provider
value={{
Expand All @@ -411,7 +479,11 @@ export default function APIProvider({ children }) {
updateUserInfo,
updatePasswords,
getDashboardData,
signUp
signUp,
getLDAPUsers,
saveLDAPenv,
getLDAPenv,
upsertLDAPuser
}}>
{children}
</APIContext.Provider>
Expand Down
27 changes: 26 additions & 1 deletion client/src/layouts/dashboard/DashboardSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import GroupIcon from '@mui/icons-material/Group'
import InsertChartIcon from '@mui/icons-material/InsertChart'
import VerifiedUserIcon from '@mui/icons-material/VerifiedUser'
import DesktopMacIcon from '@mui/icons-material/DesktopMac'
import CloudSyncIcon from '@mui/icons-material/CloudSync'

import { useAPI } from '../../contexts/apiContext'
import { styled, useTheme } from '@mui/material/styles';
Expand Down Expand Up @@ -88,7 +89,8 @@ export default function MarketplaceSidebar({ isOpenSidebar, onCloseSidebar }) {
'manageUsers': '/gerenciar_usuarios',
'dashboard': '/dashboard',
'authUser': '/autorizar_usuarios',
'manageApplications': '/gerenciar_aplicacoes'
'manageApplications': '/gerenciar_aplicacoes',
'manageLDAP': '/sincronizar_usuarios_ldap'
}

useEffect(() => {
Expand Down Expand Up @@ -195,6 +197,29 @@ export default function MarketplaceSidebar({ isOpenSidebar, onCloseSidebar }) {
<ListItemText primary={'Gerenciar aplicações'} sx={{ opacity: isOpenSidebar ? 1 : 0 }} />
</ListItemButton>
</Tooltip>
<Tooltip title="Sincronizar usuários LDAP">
<ListItemButton
sx={{
minHeight: 48,
justifyContent: isOpenSidebar ? 'initial' : 'center',
px: 2.5,
}}
component={RouterLink}
to={routers['manageLDAP']}
selected={routers['manageLDAP'] === pathname}
>
<ListItemIcon
sx={{
minWidth: 0,
mr: isOpenSidebar ? 3 : 'auto',
justifyContent: 'center',
}}
>
<CloudSyncIcon />
</ListItemIcon>
<ListItemText primary={'Sincronizar usuários LDAP'} sx={{ opacity: isOpenSidebar ? 1 : 0 }} />
</ListItemButton>
</Tooltip>
</>
)
}
Expand Down
17 changes: 17 additions & 0 deletions client/src/pages/LDAPManagePage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import {
Container,
} from '@mui/material';
import Page from '../components/Page';
import { LDAPInfoCard } from '../sections/@user';

export default function LDAPManagePage() {

return (
<Page title="Sincronizar usuários LDAP">
<Container maxWidth='sm'>
<LDAPInfoCard/>
</Container>
</Page>
);
}
2 changes: 2 additions & 0 deletions client/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const UsersAuthPage = lazy(() => import('./pages/UsersAuthPage'))
const ApplicationsManagePage = lazy(() => import('./pages/ApplicationsManagePage'))
const DashboardPage = lazy(() => import('./pages/DashboardPage'))
const SignUpPage = lazy(() => import('./pages/SignUpPage'))
const LDAPManagePage = lazy(() => import('./pages/LDAPManagePage'))

export default function Router() {
return useRoutes([
Expand All @@ -27,6 +28,7 @@ export default function Router() {
{ path: '/autorizar_usuarios', element: <PrivateRoute><UsersAuthPage /></PrivateRoute> },
{ path: '/gerenciar_aplicacoes', element: <PrivateRoute><ApplicationsManagePage /></PrivateRoute> },
{ path: '/dashboard', element: <PrivateRoute><DashboardPage /></PrivateRoute> },
{ path: '/sincronizar_usuarios_ldap', element: <PrivateRoute><LDAPManagePage /></PrivateRoute> },
]
},
{
Expand Down
Loading