Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cf-online-api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KS Pardubický kraj
cf-online-api
Commits
aba79ef3
Verified
Commit
aba79ef3
authored
4 years ago
by
Andrej Ramašeuski
Browse files
Options
Downloads
Patches
Plain Diff
Vyhledavac
parent
25ab0d2e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/CF/Controller/SSO.pm
+117
-0
117 additions, 0 deletions
lib/CF/Controller/SSO.pm
openapi.yaml
+45
-0
45 additions, 0 deletions
openapi.yaml
with
162 additions
and
0 deletions
lib/CF/Controller/SSO.pm
0 → 100644
+
117
−
0
View file @
aba79ef3
package
CF::Controller::
SSO
;
use
Mojo::
Base
'
Mojolicious::Controller
';
use
Mojo::Pg::
PubSub
;
use
feature
'
signatures
';
no
warnings
qw{ experimental::signatures }
;
use
Mojo::
UserAgent
;
sub
subjects
($c) {
$c
->
openapi
->
valid_input
or
return
;
my
$args
=
$c
->
validation
->
output
;
my
(
$groups
,
$users
,
@subjects
);
if
(
$args
->
{
class
}
=~
/all|group/
)
{
@subjects
=
$c
->
_groups
(
$args
->
{
search
}
);
}
if
(
$args
->
{
class
}
=~
/all|user/
)
{
@subjects
=
(
@subjects
,
$c
->
_users
(
$args
->
{
search
}
));
}
$c
->
render
(
openapi
=>
\
@subjects
);
}
sub
_groups
($c, $search) {
my
$ua
=
Mojo::
UserAgent
->
new
;
my
@groups
=
();
my
$groups
;
eval
{
$groups
=
$ua
->
get
(
sprintf
(
$c
->
config
->
{
iapi_get_groups
},
$search
)
)
->
result
->
json
;
};
if
(
$groups
&&
ref
$groups
eq
'
ARRAY
'
)
{
my
@tmp
=
();
# vyssi priorita pri vyskytu na zacatku
GROUP:
foreach
my
$group
(
@
{
$groups
}
)
{
next
if
$group
->
{
code
}
=~
/^_group/
;
# nezarazene skupiny
next
if
$group
->
{
name
}
=~
/^@/
;
# zavinacove skupiny
$group
->
{
priority
}
=
0
;
$group
->
{
priority
}
=
1
if
$group
->
{
name
}
=~
/^$search/i
;
$group
->
{
priority
}
=
2
if
$group
->
{
code
}
=~
/^$search/i
;
push
@tmp
,
$group
,
}
GROUP:
foreach
my
$group
(
sort
{
$b
->
{
priority
}
<=>
$a
->
{
priority
}
or
lc
(
$a
->
{
name
})
cmp
lc
(
$b
->
{
name
})
or
lc
(
$a
->
{
code
})
cmp
lc
(
$b
->
{
code
})
}
@tmp
)
{
push
@groups
,
{
class
=>
'
group
',
value
=>
$group
->
{
code
},
label
=>
$group
->
{
name
},
};
}
}
return
@groups
;
}
sub
_users
($c, $search) {
my
$ua
=
Mojo::
UserAgent
->
new
;
my
@users
=
();
my
$users
;
eval
{
$users
=
$ua
->
get
(
sprintf
(
$c
->
config
->
{
iapi_get_users
},
$search
)
)
->
result
->
json
;
};
if
(
$users
&&
ref
$users
eq
'
ARRAY
'
)
{
my
@tmp
=
();
# vyssi priorita pri vyskytu na zacatku
USER:
foreach
my
$user
(
@
{
$users
}
)
{
$user
->
{
priority
}
=
0
;
$user
->
{
priority
}
=
1
if
$user
->
{
lastname
}
=~
/^$search/i
;
$user
->
{
priority
}
=
2
if
$user
->
{
username
}
=~
/^$search/i
;
$user
->
{
priority
}
=
3
if
$user
->
{
firstname
}
=~
/^$search/i
;
push
@tmp
,
$user
,
}
USER:
foreach
my
$user
(
sort
{
$b
->
{
priority
}
<=>
$a
->
{
priority
}
or
lc
(
$a
->
{
firstname
})
cmp
lc
(
$b
->
{
firstname
})
or
lc
(
$a
->
{
lastname
})
cmp
lc
(
$b
->
{
lastname
})
}
@tmp
)
{
push
@users
,
{
class
=>
'
user
',
value
=>
$user
->
{
username
},
label
=>
$user
->
{
displayname
}
||
$user
->
{
firstname
}
.
'
'
.
$user
->
{
lastname
},
};
}
}
return
@users
;
}
1
;
This diff is collapsed.
Click to expand it.
openapi.yaml
+
45
−
0
View file @
aba79ef3
...
...
@@ -98,6 +98,15 @@ components:
type
:
integer
my_vote
:
type
:
integer
Option
:
type
:
object
properties
:
class
:
type
:
string
value
:
type
:
string
label
:
type
:
string
PostHistoryItem
:
type
:
object
properties
:
...
...
@@ -215,6 +224,42 @@ paths:
204
:
description
:
Program entry updated
/sso/subjects
:
get
:
x-mojo-to
:
SSO#subjects
tags
:
-
config
summary
:
"
Subjekty
SSO"
operationId
:
getSubjects
parameters
:
-
name
:
search
in
:
query
description
:
"
Retezec
pro
vyhledavani"
required
:
true
schema
:
type
:
string
minLength
:
3
pattern
:
'
^[\w:\.\-]{3,}$'
example
:
'
cen:'
-
name
:
class
in
:
query
description
:
"
Trida
subjektu"
required
:
true
schema
:
type
:
string
enum
:
[
all
,
user
,
group
]
example
:
group
default
:
all
responses
:
200
:
description
:
Seznam subjektu
content
:
application/json
:
schema
:
type
:
array
items
:
$ref
:
'
#/components/schemas/Option'
/program
:
get
:
x-mojo-to
:
program#entries
...
...
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