Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
authdb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jan.koester
authdb
Commits
5d2298b7
Commit
5d2298b7
authored
4 weeks ago
by
jan.koester
Browse files
Options
Downloads
Patches
Plain Diff
work work
parent
12f2d7aa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/authdb.cpp
+134
-0
134 additions, 0 deletions
src/authdb.cpp
src/group.cpp
+8
-0
8 additions, 0 deletions
src/group.cpp
with
142 additions
and
0 deletions
src/authdb.cpp
+
134
−
0
View file @
5d2298b7
...
@@ -985,8 +985,142 @@ namespace authdb {
...
@@ -985,8 +985,142 @@ namespace authdb {
}
}
void
createGroup
(
libhttppp
::
HttpRequest
*
curreq
,
const
int
tid
,
ULONG_PTR
args
,
const
char
*
url
){
void
createGroup
(
libhttppp
::
HttpRequest
*
curreq
,
const
int
tid
,
ULONG_PTR
args
,
const
char
*
url
){
libhtmlpp
::
HtmlString
form
,
out
;
libhtmlpp
::
HtmlElement
root
=
_IndexElement
,
*
content
=
root
.
getElementbyID
(
"content"
);
char
cdid
[
255
];
uuid_t
did
;
if
(
sscanf
(
curreq
->
getRequestURL
(),
"/settings/%[^/]"
,
cdid
)
<
0
){
throw
AuthBackendError
(
"createGroups: wrong url!"
);
}
DomainBackend
dbackend
(
_AdminBackend
);
AuthBackend
*
backend
=
nullptr
;
if
(
strcmp
(
cdid
,
"admin"
)
!=
0
){
if
(
uuid_parse
(
cdid
,
did
)
<
0
)
throw
AuthBackendError
(
"createGroups: wrong domain id !"
);
backend
=
dbackend
.
data
(
did
);
}
else
{
backend
=&
_AdminBackend
;
}
if
(
!
backend
)
throw
AuthBackendError
(
"createGroups: no backend seleted!"
);
libhttppp
::
HttpForm
curform
;
curform
.
parse
(
curreq
);
if
(
curform
.
getBoundary
())
{
size_t
gcount
=
0
;
std
::
string
gname
;
uuid_t
gid
;
uuid_generate
(
gid
);
class
GroupData
grp
(
gid
);
for
(
libhttppp
::
HttpForm
::
MultipartForm
::
Data
*
curformdat
=
curform
.
MultipartFormData
.
getFormData
();
curformdat
;
curformdat
=
curformdat
->
nextData
())
{
if
(
curformdat
->
Value
.
empty
())
continue
;
for
(
libhttppp
::
HttpForm
::
MultipartForm
::
Data
::
ContentDisposition
*
curdispo
=
curformdat
->
getDisposition
();
curdispo
;
curdispo
=
curdispo
->
nextContentDisposition
()
){
std
::
string
tmp
=
curdispo
->
getKey
();
std
::
transform
(
tmp
.
begin
(),
tmp
.
end
(),
tmp
.
begin
(),
[](
unsigned
char
c
){
return
std
::
tolower
(
c
);
});
if
(
tmp
==
"name"
&&
strcmp
(
curdispo
->
getValue
(),
"members"
)
==
0
){
++
gcount
;
}
if
(
tmp
==
"name"
&&
strcmp
(
curdispo
->
getValue
(),
"groupname"
)
==
0
){
std
::
copy
(
curformdat
->
Value
.
begin
(),
curformdat
->
Value
.
end
(),
std
::
back_inserter
(
gname
));
}
}
}
if
(
gname
.
empty
())
throw
AuthBackendError
(
"createGroups: no doamin name given"
);
grp
.
Members
->
count
=
gcount
;
grp
.
Members
->
uid
=
new
uuid_t
[
gcount
];
size_t
git
=
0
;
for
(
libhttppp
::
HttpForm
::
MultipartForm
::
Data
*
curformdat
=
curform
.
MultipartFormData
.
getFormData
();
curformdat
;
curformdat
=
curformdat
->
nextData
())
{
for
(
libhttppp
::
HttpForm
::
MultipartForm
::
Data
::
ContentDisposition
*
curdispo
=
curformdat
->
getDisposition
();
curdispo
;
curdispo
=
curdispo
->
nextContentDisposition
()
){
std
::
string
tmp
=
curdispo
->
getKey
();
std
::
transform
(
tmp
.
begin
(),
tmp
.
end
(),
tmp
.
begin
(),
[](
unsigned
char
c
){
return
std
::
tolower
(
c
);
});
if
(
tmp
==
"name"
&&
strcmp
(
curdispo
->
getValue
(),
"members"
)
==
0
){
uuid_parse
(
curformdat
->
Value
.
data
(),
grp
.
Members
->
uid
[
git
]);
++
git
;
}
}
}
delete
[]
grp
.
Members
->
uid
;
}
size_t
rd
=
sizeof
(
authdb
::
AuthHeader
),
end
=
backend
->
end
();
form
<<
"<form method=
\"
post
\"
enctype=
\"
multipart/form-data
\"
>"
<<
"<table>"
<<
"<tr><th>Create Group:</th></tr>"
<<
"<tr><td><label for=
\"
groupname
\"
>groupname:</label></td>"
<<
"<td><input type=
\"
text
\"
name=
\"
groupname
\"
></td></tr>"
<<
"<tr><td>Members:</td>"
<<
"<td><select name=
\"
members
\"
multiple>"
;
while
(
rd
<
end
){
authdb
::
AuthData
::
Record
cur
;
cur
.
type
=
EmptyData
;
backend
->
setPos
(
rd
);
backend
->
read
((
unsigned
char
*
)
&
cur
,
sizeof
(
AuthData
::
Record
));
rd
=
backend
->
getPos
()
+
cur
.
datasize
;
if
(
cur
.
type
==
UserData
&&
strcmp
(
cur
.
fieldname
,
"username"
)
==
0
){
cur
.
data
=
new
char
[
cur
.
datasize
];
backend
->
read
((
unsigned
char
*
)
cur
.
data
,
cur
.
datasize
);
char
cuid
[
255
];
uuid_unparse
(
cur
.
uuid
,
cuid
);
form
<<
"<option value=
\"
"
<<
cuid
<<
"
\"
>"
<<
cur
.
data
<<
"</option>"
;
delete
[]
cur
.
data
;
}
}
form
<<
"</select></td></tr>"
<<
"<tr><td></td><td><input type=
\"
submit
\"
value=
\"
Create group
\"
></td></tr>"
<<
"</table>"
<<
"</form"
;
content
->
appendChild
(
form
.
parse
());
libhtmlpp
::
print
(
&
root
,
out
,
true
);
libhttppp
::
HttpResponse
rep
;
rep
.
setContentType
(
"text/html"
);
rep
.
setContentLength
(
out
.
size
());
rep
.
send
(
curreq
,
out
.
c_str
(),
out
.
size
());
}
}
void
SettingsController
(
libhttppp
::
HttpRequest
*
curreq
,
const
int
tid
,
ULONG_PTR
args
){
void
SettingsController
(
libhttppp
::
HttpRequest
*
curreq
,
const
int
tid
,
ULONG_PTR
args
){
...
...
This diff is collapsed.
Click to expand it.
src/group.cpp
+
8
−
0
View file @
5d2298b7
...
@@ -26,3 +26,11 @@
...
@@ -26,3 +26,11 @@
*******************************************************************************/
*******************************************************************************/
#include
"group.h"
#include
"group.h"
authdb
::
GroupData
::
GroupData
(
uuid_t
gid
){
Members
=
new
GroupData
::
MemberUids
;
}
authdb
::
GroupData
::~
GroupData
(){
delete
Members
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment