Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
user-discovery-bot
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
archives
user-discovery-bot
Commits
4e91ecf5
Commit
4e91ecf5
authored
Jan 14, 2022
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Move verify
parent
ba97330c
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!50
Revert "update deps"
,
!48
Release
,
!42
Add username field to users table for raw username
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
io/userRegistration.go
+16
-11
16 additions, 11 deletions
io/userRegistration.go
with
16 additions
and
11 deletions
io/userRegistration.go
+
16
−
11
View file @
4e91ecf5
...
...
@@ -33,7 +33,7 @@ func registerUser(msg *pb.UDBUserRegistration, permPublicKey *rsa.PublicKey,
}
// Parse the username and UserID
username
:=
msg
.
IdentityRegistration
.
Username
// TODO: this & msg.Frs.Fact
seems redundant
username
:=
msg
.
Frs
.
Fact
.
Fact
// TODO: this & msg.
IdentityRegistration.Username seems redundant
uid
,
err
:=
id
.
Unmarshal
(
msg
.
UID
)
if
err
!=
nil
{
return
&
messages
.
Ack
{},
errors
.
New
(
"Could not parse UID sent over. "
+
...
...
@@ -47,7 +47,7 @@ func registerUser(msg *pb.UDBUserRegistration, permPublicKey *rsa.PublicKey,
flattened
:=
flatten
(
username
)
// Check if username is taken
err
=
store
.
CheckUser
(
flattened
,
uid
)
// TODO: this should take flattened
err
=
store
.
CheckUser
(
flattened
,
uid
)
if
err
!=
nil
{
return
&
messages
.
Ack
{},
errors
.
Errorf
(
"Username %s is already taken. "
+
"Please try again"
,
username
)
...
...
@@ -68,27 +68,32 @@ func registerUser(msg *pb.UDBUserRegistration, permPublicKey *rsa.PublicKey,
return
&
messages
.
Ack
{},
errors
.
New
(
"Could not parse key passed in"
)
}
// Verify the signed identity data
hashedIdentity
:=
msg
.
IdentityRegistration
.
Digest
()
err
=
rsa
.
Verify
(
clientPubKey
,
hash
.
CMixHash
,
hashedIdentity
,
msg
.
IdentitySignature
,
nil
)
if
err
!=
nil
{
return
&
messages
.
Ack
{},
errors
.
New
(
"Could not verify identity signature"
)
}
// Verify the signed fact
tf
,
err
:=
fact
.
NewFact
(
fact
.
FactType
(
msg
.
Frs
.
Fact
.
FactType
),
msg
.
Frs
.
Fact
.
Fact
)
if
err
!=
nil
{
return
&
messages
.
Ack
{},
errors
.
WithMessage
(
err
,
"Failed to hash fact"
)
}
hashedFact
:=
factID
.
Fingerprint
(
tf
)
hashedFact
:=
factID
.
Fingerprint
(
tf
)
// TODO: does fingerprint still need to uppercase the fact?
err
=
rsa
.
Verify
(
clientPubKey
,
hash
.
CMixHash
,
hashedFact
,
msg
.
Frs
.
FactSig
,
nil
)
if
err
!=
nil
{
return
&
messages
.
Ack
{},
errors
.
New
(
"Could not verify fact signature"
)
}
flattendFact
,
err
:=
fact
.
NewFact
(
fact
.
FactType
(
msg
.
Frs
.
Fact
.
FactType
),
flattened
)
if
err
!=
nil
{
return
&
messages
.
Ack
{},
errors
.
WithMessage
(
err
,
"Failed to hash flattened fact"
)
}
// Verify the signed identity data
hashedIdentity
:=
msg
.
IdentityRegistration
.
Digest
()
err
=
rsa
.
Verify
(
clientPubKey
,
hash
.
CMixHash
,
hashedIdentity
,
msg
.
IdentitySignature
,
nil
)
if
err
!=
nil
{
return
&
messages
.
Ack
{},
errors
.
New
(
"Could not verify identity signature"
)
}
// Create fact off of username
f
:=
storage
.
Fact
{
Hash
:
hashe
dFact
,
Hash
:
factID
.
Fingerprint
(
flatten
dFact
)
,
UserId
:
msg
.
UID
,
Fact
:
flattened
,
Type
:
uint8
(
msg
.
Frs
.
Fact
.
FactType
),
...
...
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