Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ai3
accountserver
Commits
51a509d3
Commit
51a509d3
authored
May 17, 2020
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose websites' statsId via the API
Fixes issue
#15
.
parent
d148c470
Pipeline
#6820
passed with stages
in 2 minutes and 8 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
backend/ldap/resources.go
backend/ldap/resources.go
+13
-0
backend/ldap/resources_test.go
backend/ldap/resources_test.go
+1
-0
types.go
types.go
+1
-0
No files found.
backend/ldap/resources.go
View file @
51a509d3
...
...
@@ -349,6 +349,7 @@ func (h *websiteResourceHandler) FromLDAP(entry *ldap.Entry) (*as.Resource, erro
//name := fmt.Sprintf("%s/%s", parentSite, alias)
url
:=
fmt
.
Sprintf
(
"https://www.%s/%s/"
,
parentSite
,
alias
)
uid
,
_
:=
strconv
.
Atoi
(
entry
.
GetAttributeValue
(
uidNumberLDAPAttr
))
// nolint
statsID
,
_
:=
strconv
.
Atoi
(
entry
.
GetAttributeValue
(
"statsId"
))
// nolint
return
&
as
.
Resource
{
ID
:
as
.
ResourceID
(
entry
.
DN
),
...
...
@@ -361,10 +362,18 @@ func (h *websiteResourceHandler) FromLDAP(entry *ldap.Entry) (*as.Resource, erro
Options
:
entry
.
GetAttributeValues
(
"option"
),
DocumentRoot
:
entry
.
GetAttributeValue
(
"documentRoot"
),
AcceptMail
:
false
,
StatsID
:
statsID
,
},
},
nil
}
func
nonZeroIntToList
(
i
int
)
[]
string
{
if
i
==
0
{
return
nil
}
return
[]
string
{
strconv
.
Itoa
(
i
)}
}
func
(
h
*
websiteResourceHandler
)
ToLDAP
(
rsrc
*
as
.
Resource
)
[]
ldap
.
PartialAttribute
{
//bareName := strings.Split(rsrc.Name, "/")[0]
return
[]
ldap
.
PartialAttribute
{
...
...
@@ -374,6 +383,7 @@ func (h *websiteResourceHandler) ToLDAP(rsrc *as.Resource) []ldap.PartialAttribu
{
Type
:
"option"
,
Vals
:
rsrc
.
Website
.
Options
},
{
Type
:
"documentRoot"
,
Vals
:
s2l
(
rsrc
.
Website
.
DocumentRoot
)},
{
Type
:
uidNumberLDAPAttr
,
Vals
:
s2l
(
strconv
.
Itoa
(
rsrc
.
Website
.
UID
))},
{
Type
:
"statsId"
,
Vals
:
nonZeroIntToList
(
rsrc
.
Website
.
StatsID
)},
}
}
...
...
@@ -409,6 +419,7 @@ func (h *domainResourceHandler) FromLDAP(entry *ldap.Entry) (*as.Resource, error
cn
:=
entry
.
GetAttributeValue
(
"cn"
)
uid
,
_
:=
strconv
.
Atoi
(
entry
.
GetAttributeValue
(
uidNumberLDAPAttr
))
// nolint
statsID
,
_
:=
strconv
.
Atoi
(
entry
.
GetAttributeValue
(
"statsId"
))
// nolint
return
&
as
.
Resource
{
ID
:
as
.
ResourceID
(
entry
.
DN
),
...
...
@@ -420,6 +431,7 @@ func (h *domainResourceHandler) FromLDAP(entry *ldap.Entry) (*as.Resource, error
Options
:
entry
.
GetAttributeValues
(
"option"
),
DocumentRoot
:
entry
.
GetAttributeValue
(
"documentRoot"
),
AcceptMail
:
s2b
(
entry
.
GetAttributeValue
(
"acceptMail"
)),
StatsID
:
statsID
,
},
},
nil
}
...
...
@@ -432,6 +444,7 @@ func (h *domainResourceHandler) ToLDAP(rsrc *as.Resource) []ldap.PartialAttribut
{
Type
:
"documentRoot"
,
Vals
:
s2l
(
rsrc
.
Website
.
DocumentRoot
)},
{
Type
:
"acceptMail"
,
Vals
:
s2l
(
b2s
(
rsrc
.
Website
.
AcceptMail
))},
{
Type
:
uidNumberLDAPAttr
,
Vals
:
s2l
(
strconv
.
Itoa
(
rsrc
.
Website
.
UID
))},
{
Type
:
"statsId"
,
Vals
:
nonZeroIntToList
(
rsrc
.
Website
.
StatsID
)},
}
}
...
...
backend/ldap/resources_test.go
View file @
51a509d3
...
...
@@ -72,6 +72,7 @@ func TestResource_LDAPSerialization(t *testing.T) {
AcceptMail
:
true
,
Options
:
[]
string
{
"php"
,
"sendmail"
},
DocumentRoot
:
"/home/web/root"
,
StatsID
:
12345
,
},
},
...
...
types.go
View file @
51a509d3
...
...
@@ -572,6 +572,7 @@ type Website struct {
Description
map
[
string
]
string
`json:"description,omitempty"`
QuotaUsage
int
`json:"quota_usage"`
DocumentRoot
string
`json:"document_root"`
StatsID
int
`json:"stats_id"`
CMSInfo
[]
*
webappdb
.
App
`json:"cms_info,omitempty"`
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment