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
3a6551c7
Commit
3a6551c7
authored
Apr 03, 2023
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement "allow-tokens".
parent
ac1dc77b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
README
README
+2
-0
group/group.go
group/group.go
+16
-4
group/group_test.go
group/group_test.go
+3
-3
No files found.
README
View file @
3a6551c7
...
@@ -111,6 +111,8 @@ following fields are allowed:
...
@@ -111,6 +111,8 @@ following fields are allowed:
- `max-history-age`: the time, in seconds, during which chat history is
- `max-history-age`: the time, in seconds, during which chat history is
kept (default 14400, i.e. 4 hours);
kept (default 14400, i.e. 4 hours);
- `allow-recording`: if true, then recording is allowed in this group;
- `allow-recording`: if true, then recording is allowed in this group;
- `allow-tokens`: if true, then ordinary users (without the "op" privilege)
are allowed to create tokens;
- `allow-anonymous`: if true, then users may connect with an empty username;
- `allow-anonymous`: if true, then users may connect with an empty username;
- `allow-subgroups`: if true, then subgroups of the form `group/subgroup`
- `allow-subgroups`: if true, then subgroups of the form `group/subgroup`
are automatically created when first accessed;
are automatically created when first accessed;
...
...
group/group.go
View file @
3a6551c7
...
@@ -953,6 +953,9 @@ type Description struct {
...
@@ -953,6 +953,9 @@ type Description struct {
// Whether recording is allowed.
// Whether recording is allowed.
AllowRecording
bool
`json:"allow-recording,omitempty"`
AllowRecording
bool
`json:"allow-recording,omitempty"`
// Whether creating tokens is allowed
AllowTokens
bool
`json:"allow-tokens,omitempty"`
// Whether subgroups are created on the fly.
// Whether subgroups are created on the fly.
AllowSubgroups
bool
`json:"allow-subgroups,omitempty"`
AllowSubgroups
bool
`json:"allow-subgroups,omitempty"`
...
@@ -1115,22 +1118,31 @@ func (g *Group) getPasswordPermission(creds ClientCredentials) ([]string, error)
...
@@ -1115,22 +1118,31 @@ func (g *Group) getPasswordPermission(creds ClientCredentials) ([]string, error)
}
}
if
found
,
good
:=
matchClient
(
creds
,
desc
.
Op
);
found
{
if
found
,
good
:=
matchClient
(
creds
,
desc
.
Op
);
found
{
if
good
{
if
good
{
p
:=
[]
string
{
"op"
,
"present"
,
"token"
}
if
desc
.
AllowRecording
{
if
desc
.
AllowRecording
{
return
[]
string
{
"op"
,
"present"
,
"record"
},
nil
p
=
append
(
p
,
"record"
)
}
}
return
[]
string
{
"op"
,
"present"
}
,
nil
return
p
,
nil
}
}
return
nil
,
ErrNotAuthorised
return
nil
,
ErrNotAuthorised
}
}
if
found
,
good
:=
matchClient
(
creds
,
desc
.
Presenter
);
found
{
if
found
,
good
:=
matchClient
(
creds
,
desc
.
Presenter
);
found
{
if
good
{
if
good
{
return
[]
string
{
"present"
},
nil
p
:=
[]
string
{
"present"
}
if
desc
.
AllowTokens
{
p
=
append
(
p
,
"token"
)
}
return
p
,
nil
}
}
return
nil
,
ErrNotAuthorised
return
nil
,
ErrNotAuthorised
}
}
if
found
,
good
:=
matchClient
(
creds
,
desc
.
Other
);
found
{
if
found
,
good
:=
matchClient
(
creds
,
desc
.
Other
);
found
{
if
good
{
if
good
{
return
nil
,
nil
p
:=
[]
string
{}
if
desc
.
AllowTokens
{
p
=
append
(
p
,
"token"
)
}
return
p
,
nil
}
}
return
nil
,
ErrNotAuthorised
return
nil
,
ErrNotAuthorised
}
}
...
...
group/group_test.go
View file @
3a6551c7
...
@@ -128,7 +128,7 @@ type credPerm struct {
...
@@ -128,7 +128,7 @@ type credPerm struct {
var
goodClients
=
[]
credPerm
{
var
goodClients
=
[]
credPerm
{
{
{
ClientCredentials
{
Username
:
&
jch
,
Password
:
"topsecret"
},
ClientCredentials
{
Username
:
&
jch
,
Password
:
"topsecret"
},
[]
string
{
"op"
,
"present"
},
[]
string
{
"op"
,
"present"
,
"token"
},
},
},
{
{
ClientCredentials
{
Username
:
&
john
,
Password
:
"secret"
},
ClientCredentials
{
Username
:
&
john
,
Password
:
"secret"
},
...
@@ -140,11 +140,11 @@ var goodClients = []credPerm{
...
@@ -140,11 +140,11 @@ var goodClients = []credPerm{
},
},
{
{
ClientCredentials
{
Username
:
&
james
,
Password
:
"secret3"
},
ClientCredentials
{
Username
:
&
james
,
Password
:
"secret3"
},
nil
,
[]
string
{}
,
},
},
{
{
ClientCredentials
{
Username
:
&
paul
,
Password
:
"secret3"
},
ClientCredentials
{
Username
:
&
paul
,
Password
:
"secret3"
},
nil
,
[]
string
{}
,
},
},
}
}
...
...
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