Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
969354e9
Commit
969354e9
authored
May 11, 2024
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Honour the kid field in JWT if present.
parent
6c019253
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
9 deletions
+18
-9
README
README
+3
-2
group/description.go
group/description.go
+1
-1
token/jwt.go
token/jwt.go
+14
-6
No files found.
README
View file @
969354e9
...
...
@@ -319,8 +319,9 @@ specify either an authorisation server or an authorisation portal.
"authServer": "https://auth.example.org",
}
If multiple keys are provided, then they will all be tried in turn (the
kid field, if provided, is ignored).
If multiple keys are provided, then they will all be tried in turn, unless
the token includes the "kid" header field, in which case only the
specified key will be used.
If an authorisation server is specified, then the default client, after it
prompts for a password, will request a token from the authorisation server
...
...
group/description.go
View file @
969354e9
...
...
@@ -581,7 +581,7 @@ func SetWildcardUser(group string, user *UserDescription) error {
func
SetKeys
(
group
string
,
keys
[]
map
[
string
]
any
)
error
{
if
keys
!=
nil
{
_
,
err
:=
token
.
ParseKeys
(
keys
)
_
,
err
:=
token
.
ParseKeys
(
keys
,
""
)
if
err
!=
nil
{
return
err
}
...
...
token/jwt.go
View file @
969354e9
...
...
@@ -96,14 +96,18 @@ func ParseKey(key map[string]any) (any, error) {
}
}
func
ParseKeys
(
keys
[]
map
[
string
]
any
)
([]
jwt
.
VerificationKey
,
error
)
{
ks
:=
make
([]
jwt
.
VerificationKey
,
len
(
keys
))
for
i
,
ky
:=
range
keys
{
func
ParseKeys
(
keys
[]
map
[
string
]
any
,
kid
string
)
([]
jwt
.
VerificationKey
,
error
)
{
ks
:=
make
([]
jwt
.
VerificationKey
,
0
,
len
(
keys
))
for
_
,
ky
:=
range
keys
{
// return all keys if kid is not specified
if
kid
!=
""
&&
ky
[
"kid"
]
!=
kid
{
continue
}
k
,
err
:=
ParseKey
(
ky
)
if
err
!=
nil
{
return
nil
,
err
}
ks
[
i
]
=
k
ks
=
append
(
ks
,
k
)
}
return
ks
,
nil
}
...
...
@@ -130,11 +134,15 @@ func toStringArray(a interface{}) ([]string, bool) {
func
parseJWT
(
token
string
,
keys
[]
map
[
string
]
any
)
(
*
JWT
,
error
)
{
t
,
err
:=
jwt
.
Parse
(
token
,
func
(
t
*
jwt
.
Token
)
(
interface
{},
error
)
{
ks
,
err
:=
ParseKeys
(
keys
)
func
(
t
*
jwt
.
Token
)
(
any
,
error
)
{
kid
,
_
:=
t
.
Header
[
"kid"
]
.
(
string
)
ks
,
err
:=
ParseKeys
(
keys
,
kid
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
ks
)
==
1
{
return
ks
[
0
],
nil
}
return
jwt
.
VerificationKeySet
{
Keys
:
ks
},
nil
},
jwt
.
WithExpirationRequired
(),
...
...
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