Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
211671ba
Commit
211671ba
authored
Jun 17, 2021
by
Sietse Ringers
Browse files
refactor: use common.NewRandomString() for generating keyshareserver usernames
parent
a9c3094e
Changes
2
Hide whitespace changes
Inline
Side-by-side
internal/common/common.go
View file @
211671ba
...
...
@@ -26,9 +26,10 @@ var Logger *logrus.Logger
var
ForceHTTPS
=
true
const
(
sessionChars
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
AlphanumericChars
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
NumericChars
=
"0123456789"
sessionTokenLength
=
20
pairingCodeChars
=
"0123456789"
pairingCodeLength
=
4
)
...
...
@@ -276,14 +277,14 @@ type SSECtx struct {
}
func
NewSessionToken
()
string
{
return
n
ewRandomString
(
sessionTokenLength
,
session
Chars
)
return
N
ewRandomString
(
sessionTokenLength
,
Alphanumeric
Chars
)
}
func
NewPairingCode
()
string
{
return
n
ewRandomString
(
pairingCodeLength
,
pairingCode
Chars
)
return
N
ewRandomString
(
pairingCodeLength
,
Numeric
Chars
)
}
func
n
ewRandomString
(
count
int
,
characterSet
string
)
string
{
func
N
ewRandomString
(
count
int
,
characterSet
string
)
string
{
r
:=
make
([]
byte
,
count
)
_
,
err
:=
rand
.
Read
(
r
)
if
err
!=
nil
{
...
...
server/keyshare/keyshareserver/server.go
View file @
211671ba
...
...
@@ -456,8 +456,7 @@ func (s *Server) handleRegister(w http.ResponseWriter, r *http.Request) {
func
(
s
*
Server
)
register
(
msg
irma
.
KeyshareEnrollment
)
(
*
irma
.
Qr
,
error
)
{
// Generate keyshare server account
username
:=
common
.
NewSessionToken
()
// TODO use newRandomString() for this when shoulder-surf is merged
username
=
username
[
:
12
]
username
:=
common
.
NewRandomString
(
12
,
common
.
AlphanumericChars
)
secrets
,
err
:=
s
.
core
.
NewUserSecrets
(
msg
.
Pin
)
if
err
!=
nil
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment