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
5ab537a6
Commit
5ab537a6
authored
Aug 26, 2016
by
Rohith
Committed by
GitHub
Aug 26, 2016
Browse files
Options
Downloads
Patches
Plain Diff
- adding the http-only option for cookies (#127)
parent
f44d6c5b
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
cli.go
+7
-0
7 additions, 0 deletions
cli.go
cookies.go
+6
-5
6 additions, 5 deletions
cookies.go
cookies_test.go
+19
-0
19 additions, 0 deletions
cookies_test.go
doc.go
+2
-0
2 additions, 0 deletions
doc.go
with
34 additions
and
5 deletions
cli.go
+
7
−
0
View file @
5ab537a6
...
...
@@ -172,6 +172,10 @@ func getCLIOptions() []cli.Flag {
Name
:
"secure-cookie"
,
Usage
:
"enforces the cookie to be secure, default to true"
,
},
cli
.
BoolFlag
{
Name
:
"http-only-cookie"
,
Usage
:
"enforces the cookie is in http only mode, default to false"
,
},
cli
.
StringSliceFlag
{
Name
:
"cookie-domain"
,
Usage
:
"a domain the access cookie is available to, defaults host header"
,
...
...
@@ -369,6 +373,9 @@ func parseCLIOptions(cx *cli.Context, config *Config) (err error) {
if
cx
.
IsSet
(
"secure-cookie"
)
{
config
.
SecureCookie
=
cx
.
Bool
(
"secure-cookie"
)
}
if
cx
.
IsSet
(
"http-only-cookie"
)
{
config
.
HTTPOnlyCookie
=
cx
.
Bool
(
"http-only-cookie"
)
}
if
cx
.
IsSet
(
"cookie-access-name"
)
{
config
.
CookieAccessName
=
cx
.
String
(
"cookie-access-name"
)
}
...
...
This diff is collapsed.
Click to expand it.
cookies.go
+
6
−
5
View file @
5ab537a6
...
...
@@ -35,6 +35,7 @@ func (r *oauthProxy) dropCookie(cx *gin.Context, name, value string, duration ti
cookie
:=
&
http
.
Cookie
{
Name
:
name
,
Domain
:
domain
,
HttpOnly
:
r
.
config
.
HTTPOnlyCookie
,
Path
:
"/"
,
Secure
:
r
.
config
.
SecureCookie
,
Value
:
value
,
...
...
This diff is collapsed.
Click to expand it.
cookies_test.go
+
19
−
0
View file @
5ab537a6
...
...
@@ -54,6 +54,25 @@ func TestDropCookie(t *testing.T) {
"we have not set the cookie, headers: %v"
,
context
.
Writer
.
Header
())
}
func
TestHTTPOnlyCookie
(
t
*
testing
.
T
)
{
p
,
_
,
_
:=
newTestProxyService
(
nil
)
context
:=
newFakeGinContext
(
"GET"
,
"/admin"
)
p
.
dropCookie
(
context
,
"test-cookie"
,
"test-value"
,
0
)
assert
.
Equal
(
t
,
context
.
Writer
.
Header
()
.
Get
(
"Set-Cookie"
),
"test-cookie=test-value; Path=/; Domain=127.0.0.1"
,
"we have not set the cookie, headers: %v"
,
context
.
Writer
.
Header
())
context
=
newFakeGinContext
(
"GET"
,
"/admin"
)
p
.
config
.
HTTPOnlyCookie
=
true
p
.
dropCookie
(
context
,
"test-cookie"
,
"test-value"
,
0
)
assert
.
Equal
(
t
,
context
.
Writer
.
Header
()
.
Get
(
"Set-Cookie"
),
"test-cookie=test-value; Path=/; Domain=127.0.0.1; HttpOnly"
,
"we have not set the cookie, headers: %v"
,
context
.
Writer
.
Header
())
}
func
TestClearAccessTokenCookie
(
t
*
testing
.
T
)
{
p
,
_
,
_
:=
newTestProxyService
(
nil
)
context
:=
newFakeGinContext
(
"GET"
,
"/admin"
)
...
...
This diff is collapsed.
Click to expand it.
doc.go
+
2
−
0
View file @
5ab537a6
...
...
@@ -138,6 +138,8 @@ type Config struct {
CookieRefreshName
string
`json:"cookie-refresh-name" yaml:"cookie-refresh-name"`
// SecureCookie enforces the cookie as secure
SecureCookie
bool
`json:"secure-cookie" yaml:"secure-cookie"`
// HTTPOnlyCookie enforces the cookie as http only
HTTPOnlyCookie
bool
`json:"http-only-cookie" yaml:"http-only-cookie"`
// MatchClaims is a series of checks, the claims in the token must match those here
MatchClaims
map
[
string
]
string
`json:"match-claims" yaml:"match-claims"`
...
...
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