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
8775ce64
Commit
8775ce64
authored
Apr 08, 2023
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep track of issuer and creation date in tokens.
parent
c501b76d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
18 deletions
+50
-18
rtpconn/webclient.go
rtpconn/webclient.go
+11
-1
static/galene.js
static/galene.js
+20
-6
token/stateful.go
token/stateful.go
+2
-0
token/stateful_test.go
token/stateful_test.go
+17
-11
No files found.
rtpconn/webclient.go
View file @
8775ce64
...
...
@@ -1748,6 +1748,14 @@ func handleClientMessage(c *webClient, m clientMessage) error {
}
}
user
:=
c
.
username
if
user
!=
""
{
tok
.
IssuedBy
=
&
user
}
now
:=
time
.
Now
()
tok
.
IssuedAt
=
&
now
new
,
err
:=
token
.
Add
(
tok
)
if
err
!=
nil
{
return
terror
(
"error"
,
err
.
Error
())
...
...
@@ -1778,7 +1786,9 @@ func handleClientMessage(c *webClient, m clientMessage) error {
}
if
tok
.
Group
!=
""
||
tok
.
Username
!=
nil
||
tok
.
Permissions
!=
nil
||
tok
.
NotBefore
!=
nil
{
tok
.
NotBefore
!=
nil
||
tok
.
IssuedBy
!=
nil
||
tok
.
IssuedAt
!=
nil
{
return
terror
(
"error"
,
"this field cannot be edited"
,
)
...
...
static/galene.js
View file @
8775ce64
...
...
@@ -2651,7 +2651,7 @@ function gotUserMessage(id, dest, username, time, privileged, kind, error, messa
displayError
(
'
Unexpected type for token
'
);
return
;
}
let
f
=
formatToken
(
message
);
let
f
=
formatToken
(
message
,
false
);
localMessage
(
f
[
0
]
+
'
:
'
+
f
[
1
]);
if
(
'
share
'
in
navigator
)
{
try
{
...
...
@@ -2676,7 +2676,7 @@ function gotUserMessage(id, dest, username, time, privileged, kind, error, messa
}
let
s
=
''
;
for
(
let
i
=
0
;
i
<
message
.
length
;
i
++
)
{
let
f
=
formatToken
(
message
[
i
]);
let
f
=
formatToken
(
message
[
i
]
,
true
);
s
=
s
+
f
[
0
]
+
'
:
'
+
f
[
1
]
+
"
\n
"
;
}
localMessage
(
s
);
...
...
@@ -2689,23 +2689,37 @@ function gotUserMessage(id, dest, username, time, privileged, kind, error, messa
/**
* @param {Object} token
* @param {boolean} [details]
*/
function
formatToken
(
token
)
{
function
formatToken
(
token
,
details
)
{
let
url
=
new
URL
(
window
.
location
.
href
);
let
params
=
new
URLSearchParams
();
params
.
append
(
'
token
'
,
token
.
token
);
url
.
search
=
params
.
toString
();
let
foruser
=
''
let
foruser
=
''
,
by
=
''
,
togroup
=
''
;
if
(
token
.
username
)
foruser
=
` for user
${
token
.
username
}
`
;
if
(
details
)
{
if
(
token
.
issuedBy
)
by
=
'
issued by
'
+
token
.
issuedBy
;
if
(
token
.
issuedAt
)
{
if
(
by
===
''
)
by
=
'
issued at
'
+
token
.
issuedAt
;
else
by
=
by
+
'
at
'
+
(
new
Date
(
token
.
issuedAt
)).
toLocaleString
();
}
}
else
{
if
(
token
.
group
)
togroup
=
'
to group
'
+
token
.
group
;
}
/** @type{Date} */
let
expires
=
null
;
if
(
token
.
expires
)
expires
=
new
Date
(
token
.
expires
);
return
[
(
expires
&&
(
expires
>=
new
Date
()))
?
`Invitation
${
foruser
}
valid until
${
expires
.
toLocaleString
()}
`
:
`Expired invitation
${
foruser
}
`
,
`Invitation
${
foruser
}
${
togroup
}${
by
}
valid until
${
expires
.
toLocaleString
()}
`
:
`Expired invitation
${
foruser
}
${
togroup
}${
by
}
`
,
url
.
toString
(),
];
}
...
...
token/stateful.go
View file @
8775ce64
...
...
@@ -19,6 +19,8 @@ type Stateful struct {
Permissions
[]
string
`json:"permissions"`
Expires
*
time
.
Time
`json:"expires"`
NotBefore
*
time
.
Time
`json:"not-before,omitempty"`
IssuedAt
*
time
.
Time
`json:"issuedAt,omitempty"`
IssuedBy
*
string
`json:"issuedBy,omitempty"`
}
func
(
token
*
Stateful
)
Clone
()
*
Stateful
{
...
...
token/stateful_test.go
View file @
8775ce64
...
...
@@ -11,23 +11,29 @@ import (
"time"
)
func
timeEqual
(
a
,
b
*
time
.
Time
)
bool
{
if
a
==
nil
&&
b
==
nil
{
return
true
}
if
a
!=
nil
&&
b
!=
nil
{
return
(
*
a
)
.
Equal
(
*
b
)
}
return
false
}
func
equal
(
a
,
b
*
Stateful
)
bool
{
if
a
.
Token
!=
b
.
Token
||
a
.
Group
!=
b
.
Group
||
!
reflect
.
DeepEqual
(
a
.
Username
,
b
.
Username
)
||
!
reflect
.
DeepEqual
(
a
.
Permissions
,
b
.
Permissions
)
{
return
false
}
if
a
.
Expires
!=
nil
&&
b
.
Expires
!=
nil
{
return
(
*
a
.
Expires
)
.
Equal
(
*
b
.
Expires
)
}
if
(
a
.
Expires
!=
nil
)
!=
(
b
.
Expires
!=
nil
)
{
!
reflect
.
DeepEqual
(
a
.
Permissions
,
b
.
Permissions
)
||
!
timeEqual
(
a
.
Expires
,
b
.
Expires
)
||
!
reflect
.
DeepEqual
(
a
.
IssuedBy
,
b
.
IssuedBy
)
||
!
timeEqual
(
a
.
IssuedAt
,
b
.
IssuedAt
)
{
return
false
}
if
a
.
NotBefore
!=
nil
&&
b
.
NotBefore
!=
nil
{
return
(
*
a
.
NotBefore
)
.
Equal
(
*
b
.
NotBefore
)
}
return
(
a
.
NotBefore
!=
nil
)
==
(
b
.
NotBefore
!=
nil
)
return
true
}
func
TestStatefulCheck
(
t
*
testing
.
T
)
{
...
...
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