Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
keycloak-proxy
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Janne Mareike Koschinski
keycloak-proxy
Commits
4e6fe6c7
Commit
4e6fe6c7
authored
Jul 3, 2018
by
Rohith
Browse files
Options
Downloads
Patches
Plain Diff
- adding the require-any-roles attributes to the resource
parent
ff204ed5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc.go
+2
-0
2 additions, 0 deletions
doc.go
resource.go
+6
-0
6 additions, 0 deletions
resource.go
resource_test.go
+5
-0
5 additions, 0 deletions
resource_test.go
with
13 additions
and
0 deletions
doc.go
+
2
−
0
View file @
4e6fe6c7
...
@@ -130,6 +130,8 @@ type Resource struct {
...
@@ -130,6 +130,8 @@ type Resource struct {
Methods
[]
string
`json:"methods" yaml:"methods"`
Methods
[]
string
`json:"methods" yaml:"methods"`
// WhiteListed permits the prefix through
// WhiteListed permits the prefix through
WhiteListed
bool
`json:"white-listed" yaml:"white-listed"`
WhiteListed
bool
`json:"white-listed" yaml:"white-listed"`
// RequireAnyRole indicates that ANY of the roles are required, the default is all
RequireAnyRole
bool
`json:"require-any-role yaml:"require-any-role"`
// Roles the roles required to access this url
// Roles the roles required to access this url
Roles
[]
string
`json:"roles" yaml:"roles"`
Roles
[]
string
`json:"roles" yaml:"roles"`
// Groups is a list of groups the user is in
// Groups is a list of groups the user is in
...
...
This diff is collapsed.
Click to expand it.
resource.go
+
6
−
0
View file @
4e6fe6c7
...
@@ -51,6 +51,12 @@ func (r *Resource) parse(resource string) (*Resource, error) {
...
@@ -51,6 +51,12 @@ func (r *Resource) parse(resource string) (*Resource, error) {
r
.
Methods
=
allHTTPMethods
r
.
Methods
=
allHTTPMethods
}
}
}
}
case
"require-any-role"
:
v
,
err
:=
strconv
.
ParseBool
(
kp
[
1
])
if
err
!=
nil
{
return
nil
,
err
}
r
.
RequireAnyRole
=
v
case
"roles"
:
case
"roles"
:
r
.
Roles
=
strings
.
Split
(
kp
[
1
],
","
)
r
.
Roles
=
strings
.
Split
(
kp
[
1
],
","
)
case
"groups"
:
case
"groups"
:
...
...
This diff is collapsed.
Click to expand it.
resource_test.go
+
5
−
0
View file @
4e6fe6c7
...
@@ -30,6 +30,7 @@ func TestDecodeResourceBad(t *testing.T) {
...
@@ -30,6 +30,7 @@ func TestDecodeResourceBad(t *testing.T) {
{
Option
:
"uri"
},
{
Option
:
"uri"
},
{
Option
:
"uri=hello"
},
{
Option
:
"uri=hello"
},
{
Option
:
"uri=/|white-listed=ERROR"
},
{
Option
:
"uri=/|white-listed=ERROR"
},
{
Option
:
"uri=/|require-any-role=BAD"
},
}
}
for
i
,
c
:=
range
cs
{
for
i
,
c
:=
range
cs
{
if
_
,
err
:=
newResource
()
.
parse
(
c
.
Option
);
err
==
nil
{
if
_
,
err
:=
newResource
()
.
parse
(
c
.
Option
);
err
==
nil
{
...
@@ -79,6 +80,10 @@ func TestResourceParseOk(t *testing.T) {
...
@@ -79,6 +80,10 @@ func TestResourceParseOk(t *testing.T) {
Option
:
"uri=/*|groups=admin"
,
Option
:
"uri=/*|groups=admin"
,
Resource
:
&
Resource
{
URL
:
"/*"
,
Methods
:
allHTTPMethods
,
Groups
:
[]
string
{
"admin"
}},
Resource
:
&
Resource
{
URL
:
"/*"
,
Methods
:
allHTTPMethods
,
Groups
:
[]
string
{
"admin"
}},
},
},
{
Option
:
"uri=/*|require-any-role=true"
,
Resource
:
&
Resource
{
URL
:
"/*"
,
Methods
:
allHTTPMethods
,
RequireAnyRole
:
true
},
},
}
}
for
i
,
x
:=
range
cs
{
for
i
,
x
:=
range
cs
{
r
,
err
:=
newResource
()
.
parse
(
x
.
Option
)
r
,
err
:=
newResource
()
.
parse
(
x
.
Option
)
...
...
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