Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-eum
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LiU IT - Infrastructure
gitlab-eum
Commits
e6fd645b
Commit
e6fd645b
authored
7 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Fix up per-user settings
parent
3ead61af
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
client/App.vue
+1
-1
1 addition, 1 deletion
client/App.vue
config.js.example
+12
-6
12 additions, 6 deletions
config.js.example
server/auth.js
+8
-1
8 additions, 1 deletion
server/auth.js
server/users.js
+11
-9
11 additions, 9 deletions
server/users.js
with
32 additions
and
17 deletions
client/App.vue
+
1
−
1
View file @
e6fd645b
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
</div>
</div>
</transition>
</transition>
<h2
class=
"mt-4 mb-3"
>
Existing external users: (
{{
external
.
length
}}
/
{{
user
.
user_limit
}}
)
</h2>
<h2
class=
"mt-4 mb-3"
>
Existing external users: (
{{
external
.
length
}}
/
<span
v-if=
"user.user_limit > 0"
>
{{
user
.
user_limit
}}
</span><span
v-else
>
∞
</span>
)
</h2>
<hr/>
<hr/>
<transition
name=
"fade"
mode=
"out-in"
>
<transition
name=
"fade"
mode=
"out-in"
>
<ul
class=
"list-unstyled"
is=
"transition-group"
name=
"flip-list"
v-if=
"external"
>
<ul
class=
"list-unstyled"
is=
"transition-group"
name=
"flip-list"
v-if=
"external"
>
...
...
This diff is collapsed.
Click to expand it.
config.js.example
+
12
−
6
View file @
e6fd645b
...
@@ -34,21 +34,27 @@ module.exports = {
...
@@ -34,21 +34,27 @@ module.exports = {
reset_password: true
reset_password: true
},
},
// Can users deactivate external users created by them
user: {
can_user_deactivate: false,
// Can users deactivate external users created by them
// Default limit of external users
can_deactivate: false,
external_limit: 5,
// Default limit of external users
external_limit: 5,
}
// Apply configuration per user
// Apply configuration per user
//
//
// *user* will contain the parameters from https://gitlab.liu.se/help/api/users.md#for-admin
// *user* will contain the parameters from https://gitlab.liu.se/help/api/users.md#for-admin
// *config* will contain the same as the `user` block
per_user: function(user, config) {
per_user: function(user, config) {
if (user.external) {
if (user.external) {
// Disallow creation by external users
// Disallow creation by external users
config.external_limit = 0
config.external_limit = 0
} else if (user.
username =~ /^[a-z]{4}[0-9]{2}$/
) {
} else if (user.
is_admin
) {
// Unlimited external users
// Unlimited external users
config.external_limit = null
config.external_limit = -1
} else if (user.username =~ /^[a-z]{4}[0-9]{2}$/) {
// More external users
config.external_limit = 15
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
server/auth.js
+
8
−
1
View file @
e6fd645b
...
@@ -15,6 +15,13 @@ var _strategy = new GitLabStrategy({
...
@@ -15,6 +15,13 @@ var _strategy = new GitLabStrategy({
baseURL
:
config
.
gitlab
.
url
baseURL
:
config
.
gitlab
.
url
},
(
access
,
refresh
,
profile
,
cb
)
=>
{
},
(
access
,
refresh
,
profile
,
cb
)
=>
{
var
user
=
Object
.
assign
({},
profile
,
{
_token
:
access
,
_refresh
:
refresh
});
var
user
=
Object
.
assign
({},
profile
,
{
_token
:
access
,
_refresh
:
refresh
});
var
userConfig
=
Object
.
assign
({},
config
.
user
);
if
(
typeof
(
config
.
per_user
)
===
'
function
'
)
{
config
.
per_user
(
Object
.
assign
({},
user
.
_json
),
userConfig
);
}
user
.
eum_settings
=
userConfig
cb
(
null
,
user
);
cb
(
null
,
user
);
}
}
);
);
...
@@ -40,7 +47,7 @@ router.get('/', (req, res) => {
...
@@ -40,7 +47,7 @@ router.get('/', (req, res) => {
console
.
log
(
'
GET: /auth
'
);
console
.
log
(
'
GET: /auth
'
);
if
(
req
.
user
)
{
if
(
req
.
user
)
{
res
.
send
(
Object
.
assign
({},
req
.
user
.
_json
,
{
user_limit
:
config
.
external_limit
}));
res
.
send
(
Object
.
assign
({},
req
.
user
.
_json
,
{
eum_settings
:
req
.
user
.
eum_settings
}));
}
else
{
}
else
{
res
.
status
(
401
).
send
({
message
:
'
Not authenticated
'
});
res
.
status
(
401
).
send
({
message
:
'
Not authenticated
'
});
}
}
...
...
This diff is collapsed.
Click to expand it.
server/users.js
+
11
−
9
View file @
e6fd645b
...
@@ -37,17 +37,19 @@ router.post('/', async (req, res) => {
...
@@ -37,17 +37,19 @@ router.post('/', async (req, res) => {
.
filter
(
key
=>
[
'
email
'
,
'
username
'
,
'
name
'
,
'
skype
'
,
'
linkedin
'
,
'
twitter
'
,
'
website_url
'
,
'
organization
'
,
'
bio
'
,
'
location
'
,
'
avatar
'
].
includes
(
key
)
)
.
filter
(
key
=>
[
'
email
'
,
'
username
'
,
'
name
'
,
'
skype
'
,
'
linkedin
'
,
'
twitter
'
,
'
website_url
'
,
'
organization
'
,
'
bio
'
,
'
location
'
,
'
avatar
'
].
includes
(
key
)
)
.
reduce
(
(
rs
,
key
)
=>
(
rs
[
key
]
=
req
.
body
[
key
],
rs
),
{}
);
.
reduce
(
(
rs
,
key
)
=>
(
rs
[
key
]
=
req
.
body
[
key
],
rs
),
{}
);
try
{
if
(
req
.
user
.
eum_settings
.
external_limit
>
0
)
{
const
queryText
=
'
SELECT * FROM external_users WHERE owner_id = $1
'
;
try
{
const
dbResponse
=
await
db
.
query
(
queryText
,
[
req
.
user
.
id
]);
const
queryText
=
'
SELECT * FROM external_users WHERE owner_id = $1
'
;
const
dbResponse
=
await
db
.
query
(
queryText
,
[
req
.
user
.
id
]);
if
(
dbResponse
.
rowCount
>=
config
.
external_limit
)
{
if
(
dbResponse
.
rowCount
>=
req
.
user
.
eum_settings
.
external_limit
)
{
return
res
.
status
(
403
).
send
({
'
message
'
:
'
External user limit reached
'
});
return
res
.
status
(
403
).
send
({
'
message
'
:
'
External user limit reached
'
});
}
}
catch
(
err
)
{
console
.
log
(
"
> DB Error:
"
);
console
.
log
(
err
);
return
res
.
status
(
500
).
send
({
'
message
'
:
"
Database error occured
"
});
}
}
}
catch
(
err
)
{
console
.
log
(
"
> DB Error:
"
);
console
.
log
(
err
);
return
res
.
status
(
500
).
send
({
'
message
'
:
"
Database error occured
"
});
}
}
// TODO: Apply further validation on input
// TODO: Apply further validation on input
...
...
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