Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
accountserver
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai3
accountserver
Commits
a3f4990f
Commit
a3f4990f
authored
Nov 20, 2018
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set ASPs on the user object directly
parent
8e05961d
Pipeline
#1603
passed with stages
in 1 minute and 41 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
29 deletions
+9
-29
backend/model.go
backend/model.go
+9
-29
No files found.
backend/model.go
View file @
a3f4990f
...
...
@@ -120,11 +120,11 @@ func newUser(entry *ldap.Entry) (*as.RawUser, error) {
uidNumber
,
_
:=
strconv
.
Atoi
(
entry
.
GetAttributeValue
(
uidNumberLDAPAttr
))
// nolint
user
:=
&
as
.
RawUser
{
User
:
as
.
User
{
Name
:
entry
.
GetAttributeValue
(
"uid"
),
Lang
:
entry
.
GetAttributeValue
(
preferredLanguageLDAPAttr
),
UID
:
uidNumber
,
Status
:
entry
.
GetAttributeValue
(
"status"
),
Shard
:
entry
.
GetAttributeValue
(
"host"
),
Name
:
entry
.
GetAttributeValue
(
"uid"
),
Lang
:
entry
.
GetAttributeValue
(
preferredLanguageLDAPAttr
),
UID
:
uidNumber
,
Status
:
entry
.
GetAttributeValue
(
"status"
),
Shard
:
entry
.
GetAttributeValue
(
"host"
),
LastPasswordChangeStamp
:
decodeShadowTimestamp
(
entry
.
GetAttributeValue
(
passwordLastChangeLDAPAttr
)),
AccountRecoveryHint
:
entry
.
GetAttributeValue
(
recoveryHintLDAPAttr
),
U2FRegistrations
:
decodeU2FRegistrations
(
entry
.
GetAttributeValues
(
u2fRegistrationsLDAPAttr
)),
...
...
@@ -328,41 +328,21 @@ func excludeASPFromList(asps []*appSpecificPassword, id string) []*appSpecificPa
return
out
}
func
(
tx
*
backendTX
)
setASPOnResource
(
ctx
context
.
Context
,
r
*
as
.
Resource
,
info
*
as
.
AppSpecificPasswordInfo
,
encryptedPassword
string
)
{
dn
,
err
:=
tx
.
backend
.
resources
.
GetDN
(
r
.
ID
)
if
err
!=
nil
{
return
}
// Obtain the full list of ASPs from the backend and replace/append the new one.
func
(
tx
*
backendTX
)
SetApplicationSpecificPassword
(
ctx
context
.
Context
,
user
*
as
.
User
,
info
*
as
.
AppSpecificPasswordInfo
,
encryptedPassword
string
)
error
{
dn
:=
tx
.
getUserDN
(
user
)
asps
:=
decodeAppSpecificPasswords
(
tx
.
readAttributeValues
(
ctx
,
dn
,
aspLDAPAttr
))
asps
=
append
(
excludeASPFromList
(
asps
,
info
.
ID
),
newAppSpecificPassword
(
*
info
,
encryptedPassword
))
outASPs
:=
encodeAppSpecificPasswords
(
asps
)
tx
.
setAttr
(
dn
,
aspLDAPAttr
,
outASPs
...
)
}
func
(
tx
*
backendTX
)
SetApplicationSpecificPassword
(
ctx
context
.
Context
,
user
*
as
.
User
,
info
*
as
.
AppSpecificPasswordInfo
,
encryptedPassword
string
)
error
{
for
_
,
r
:=
range
user
.
GetResourcesByType
(
as
.
ResourceTypeEmail
)
{
tx
.
setASPOnResource
(
ctx
,
r
,
info
,
encryptedPassword
)
}
return
nil
}
func
(
tx
*
backendTX
)
deleteASPOnResource
(
ctx
context
.
Context
,
r
*
as
.
Resource
,
id
string
)
{
dn
,
err
:=
tx
.
backend
.
resources
.
GetDN
(
r
.
ID
)
if
err
!=
nil
{
return
}
func
(
tx
*
backendTX
)
DeleteApplicationSpecificPassword
(
ctx
context
.
Context
,
user
*
as
.
User
,
id
string
)
error
{
dn
:=
tx
.
getUserDN
(
user
)
asps
:=
decodeAppSpecificPasswords
(
tx
.
readAttributeValues
(
ctx
,
dn
,
aspLDAPAttr
))
asps
=
excludeASPFromList
(
asps
,
id
)
outASPs
:=
encodeAppSpecificPasswords
(
asps
)
tx
.
setAttr
(
dn
,
aspLDAPAttr
,
outASPs
...
)
}
func
(
tx
*
backendTX
)
DeleteApplicationSpecificPassword
(
ctx
context
.
Context
,
user
*
as
.
User
,
id
string
)
error
{
for
_
,
r
:=
range
user
.
GetResourcesByType
(
as
.
ResourceTypeEmail
)
{
tx
.
deleteASPOnResource
(
ctx
,
r
,
id
)
}
return
nil
}
...
...
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