Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
142c96c2
Unverified
Commit
142c96c2
authored
Dec 18, 2019
by
Mark Sagi-Kazar
Browse files
Options
Downloads
Patches
Plain Diff
Fix stylecheck
parent
8c3dc0ca
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.golangci.yml
+0
-1
0 additions, 1 deletion
.golangci.yml
cmd/example-app/main.go
+2
-2
2 additions, 2 deletions
cmd/example-app/main.go
connector/saml/saml.go
+4
-4
4 additions, 4 deletions
connector/saml/saml.go
storage/kubernetes/client.go
+29
-29
29 additions, 29 deletions
storage/kubernetes/client.go
with
35 additions
and
36 deletions
.golangci.yml
+
0
−
1
View file @
142c96c2
...
@@ -16,7 +16,6 @@ linters:
...
@@ -16,7 +16,6 @@ linters:
-
wsl
-
wsl
# TODO: fix me
# TODO: fix me
-
stylecheck
-
misspell
-
misspell
-
unparam
-
unparam
-
goimports
-
goimports
...
...
This diff is collapsed.
Click to expand it.
cmd/example-app/main.go
+
2
−
2
View file @
142c96c2
...
@@ -143,7 +143,7 @@ func cmd() *cobra.Command {
...
@@ -143,7 +143,7 @@ func cmd() *cobra.Command {
ctx
:=
oidc
.
ClientContext
(
context
.
Background
(),
a
.
client
)
ctx
:=
oidc
.
ClientContext
(
context
.
Background
(),
a
.
client
)
provider
,
err
:=
oidc
.
NewProvider
(
ctx
,
issuerURL
)
provider
,
err
:=
oidc
.
NewProvider
(
ctx
,
issuerURL
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"
F
ailed to query provider %q: %v"
,
issuerURL
,
err
)
return
fmt
.
Errorf
(
"
f
ailed to query provider %q: %v"
,
issuerURL
,
err
)
}
}
var
s
struct
{
var
s
struct
{
...
@@ -153,7 +153,7 @@ func cmd() *cobra.Command {
...
@@ -153,7 +153,7 @@ func cmd() *cobra.Command {
ScopesSupported
[]
string
`json:"scopes_supported"`
ScopesSupported
[]
string
`json:"scopes_supported"`
}
}
if
err
:=
provider
.
Claims
(
&
s
);
err
!=
nil
{
if
err
:=
provider
.
Claims
(
&
s
);
err
!=
nil
{
return
fmt
.
Errorf
(
"
F
ailed to parse provider scopes_supported: %v"
,
err
)
return
fmt
.
Errorf
(
"
f
ailed to parse provider scopes_supported: %v"
,
err
)
}
}
if
len
(
s
.
ScopesSupported
)
==
0
{
if
len
(
s
.
ScopesSupported
)
==
0
{
...
...
This diff is collapsed.
Click to expand it.
connector/saml/saml.go
+
4
−
4
View file @
142c96c2
...
@@ -325,7 +325,7 @@ func (p *provider) HandlePOST(s connector.Scopes, samlResponse, inResponseTo str
...
@@ -325,7 +325,7 @@ func (p *provider) HandlePOST(s connector.Scopes, samlResponse, inResponseTo str
// Status is a required element.
// Status is a required element.
if
resp
.
Status
==
nil
{
if
resp
.
Status
==
nil
{
return
ident
,
fmt
.
Errorf
(
"
R
esponse did not contain a Status element"
)
return
ident
,
fmt
.
Errorf
(
"
r
esponse did not contain a Status element"
)
}
}
if
err
=
p
.
validateStatus
(
resp
.
Status
);
err
!=
nil
{
if
err
=
p
.
validateStatus
(
resp
.
Status
);
err
!=
nil
{
...
@@ -398,7 +398,7 @@ func (p *provider) HandlePOST(s connector.Scopes, samlResponse, inResponseTo str
...
@@ -398,7 +398,7 @@ func (p *provider) HandlePOST(s connector.Scopes, samlResponse, inResponseTo str
if
len
(
p
.
allowedGroups
)
>
0
&&
(
!
s
.
Groups
||
p
.
groupsAttr
==
""
)
{
if
len
(
p
.
allowedGroups
)
>
0
&&
(
!
s
.
Groups
||
p
.
groupsAttr
==
""
)
{
// allowedGroups set but no groups or groupsAttr. Disallowing.
// allowedGroups set but no groups or groupsAttr. Disallowing.
return
ident
,
fmt
.
Errorf
(
"
U
ser not a member of allowed groups"
)
return
ident
,
fmt
.
Errorf
(
"
u
ser not a member of allowed groups"
)
}
}
// Grab the groups.
// Grab the groups.
...
@@ -427,7 +427,7 @@ func (p *provider) HandlePOST(s connector.Scopes, samlResponse, inResponseTo str
...
@@ -427,7 +427,7 @@ func (p *provider) HandlePOST(s connector.Scopes, samlResponse, inResponseTo str
if
len
(
groupMatches
)
==
0
{
if
len
(
groupMatches
)
==
0
{
// No group membership matches found, disallowing
// No group membership matches found, disallowing
return
ident
,
fmt
.
Errorf
(
"
U
ser not a member of allowed groups"
)
return
ident
,
fmt
.
Errorf
(
"
u
ser not a member of allowed groups"
)
}
}
// Otherwise, we're good
// Otherwise, we're good
...
@@ -468,7 +468,7 @@ func (p *provider) validateStatus(status *status) error {
...
@@ -468,7 +468,7 @@ func (p *provider) validateStatus(status *status) error {
func
(
p
*
provider
)
validateSubject
(
subject
*
subject
,
inResponseTo
string
)
error
{
func
(
p
*
provider
)
validateSubject
(
subject
*
subject
,
inResponseTo
string
)
error
{
// Optional according to the spec, but again, we're going to be strict here.
// Optional according to the spec, but again, we're going to be strict here.
if
len
(
subject
.
SubjectConfirmations
)
==
0
{
if
len
(
subject
.
SubjectConfirmations
)
==
0
{
return
fmt
.
Errorf
(
"
S
ubject contained no SubjectConfirmations"
)
return
fmt
.
Errorf
(
"
s
ubject contained no SubjectConfirmations"
)
}
}
var
errs
[]
error
var
errs
[]
error
...
...
This diff is collapsed.
Click to expand it.
storage/kubernetes/client.go
+
29
−
29
View file @
142c96c2
...
@@ -55,14 +55,14 @@ type client struct {
...
@@ -55,14 +55,14 @@ type client struct {
}
}
// idToName maps an arbitrary ID, such as an email or client ID to a Kubernetes object name.
// idToName maps an arbitrary ID, such as an email or client ID to a Kubernetes object name.
func
(
c
*
client
)
idToName
(
s
string
)
string
{
func
(
c
li
*
client
)
idToName
(
s
string
)
string
{
return
idToName
(
s
,
c
.
hash
)
return
idToName
(
s
,
c
li
.
hash
)
}
}
// offlineTokenName maps two arbitrary IDs, to a single Kubernetes object name.
// offlineTokenName maps two arbitrary IDs, to a single Kubernetes object name.
// This is used when more than one field is used to uniquely identify the object.
// This is used when more than one field is used to uniquely identify the object.
func
(
c
*
client
)
offlineTokenName
(
userID
string
,
connID
string
)
string
{
func
(
c
li
*
client
)
offlineTokenName
(
userID
string
,
connID
string
)
string
{
return
offlineTokenName
(
userID
,
connID
,
c
.
hash
)
return
offlineTokenName
(
userID
,
connID
,
c
li
.
hash
)
}
}
// Kubernetes names must match the regexp '[a-z0-9]([-a-z0-9]*[a-z0-9])?'.
// Kubernetes names must match the regexp '[a-z0-9]([-a-z0-9]*[a-z0-9])?'.
...
@@ -79,7 +79,7 @@ func offlineTokenName(userID string, connID string, h func() hash.Hash) string {
...
@@ -79,7 +79,7 @@ func offlineTokenName(userID string, connID string, h func() hash.Hash) string {
return
strings
.
TrimRight
(
encoding
.
EncodeToString
(
hash
.
Sum
(
nil
)),
"="
)
return
strings
.
TrimRight
(
encoding
.
EncodeToString
(
hash
.
Sum
(
nil
)),
"="
)
}
}
func
(
c
*
client
)
urlFor
(
apiVersion
,
namespace
,
resource
,
name
string
)
string
{
func
(
c
li
*
client
)
urlFor
(
apiVersion
,
namespace
,
resource
,
name
string
)
string
{
basePath
:=
"apis/"
basePath
:=
"apis/"
if
apiVersion
==
"v1"
{
if
apiVersion
==
"v1"
{
basePath
=
"api/"
basePath
=
"api/"
...
@@ -91,10 +91,10 @@ func (c *client) urlFor(apiVersion, namespace, resource, name string) string {
...
@@ -91,10 +91,10 @@ func (c *client) urlFor(apiVersion, namespace, resource, name string) string {
}
else
{
}
else
{
p
=
path
.
Join
(
basePath
,
apiVersion
,
resource
,
name
)
p
=
path
.
Join
(
basePath
,
apiVersion
,
resource
,
name
)
}
}
if
strings
.
HasSuffix
(
c
.
baseURL
,
"/"
)
{
if
strings
.
HasSuffix
(
c
li
.
baseURL
,
"/"
)
{
return
c
.
baseURL
+
p
return
c
li
.
baseURL
+
p
}
}
return
c
.
baseURL
+
"/"
+
p
return
c
li
.
baseURL
+
"/"
+
p
}
}
// Define an error interface so we can get at the underlying status code if it's
// Define an error interface so we can get at the underlying status code if it's
...
@@ -156,13 +156,13 @@ func closeResp(r *http.Response) {
...
@@ -156,13 +156,13 @@ func closeResp(r *http.Response) {
r
.
Body
.
Close
()
r
.
Body
.
Close
()
}
}
func
(
c
*
client
)
get
(
resource
,
name
string
,
v
interface
{})
error
{
func
(
c
li
*
client
)
get
(
resource
,
name
string
,
v
interface
{})
error
{
return
c
.
getResource
(
c
.
apiVersion
,
c
.
namespace
,
resource
,
name
,
v
)
return
c
li
.
getResource
(
c
li
.
apiVersion
,
c
li
.
namespace
,
resource
,
name
,
v
)
}
}
func
(
c
*
client
)
getResource
(
apiVersion
,
namespace
,
resource
,
name
string
,
v
interface
{})
error
{
func
(
c
li
*
client
)
getResource
(
apiVersion
,
namespace
,
resource
,
name
string
,
v
interface
{})
error
{
url
:=
c
.
urlFor
(
apiVersion
,
namespace
,
resource
,
name
)
url
:=
c
li
.
urlFor
(
apiVersion
,
namespace
,
resource
,
name
)
resp
,
err
:=
c
.
client
.
Get
(
url
)
resp
,
err
:=
c
li
.
client
.
Get
(
url
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -173,22 +173,22 @@ func (c *client) getResource(apiVersion, namespace, resource, name string, v int
...
@@ -173,22 +173,22 @@ func (c *client) getResource(apiVersion, namespace, resource, name string, v int
return
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
v
)
return
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
v
)
}
}
func
(
c
*
client
)
list
(
resource
string
,
v
interface
{})
error
{
func
(
c
li
*
client
)
list
(
resource
string
,
v
interface
{})
error
{
return
c
.
get
(
resource
,
""
,
v
)
return
c
li
.
get
(
resource
,
""
,
v
)
}
}
func
(
c
*
client
)
post
(
resource
string
,
v
interface
{})
error
{
func
(
c
li
*
client
)
post
(
resource
string
,
v
interface
{})
error
{
return
c
.
postResource
(
c
.
apiVersion
,
c
.
namespace
,
resource
,
v
)
return
c
li
.
postResource
(
c
li
.
apiVersion
,
c
li
.
namespace
,
resource
,
v
)
}
}
func
(
c
*
client
)
postResource
(
apiVersion
,
namespace
,
resource
string
,
v
interface
{})
error
{
func
(
c
li
*
client
)
postResource
(
apiVersion
,
namespace
,
resource
string
,
v
interface
{})
error
{
body
,
err
:=
json
.
Marshal
(
v
)
body
,
err
:=
json
.
Marshal
(
v
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"marshal object: %v"
,
err
)
return
fmt
.
Errorf
(
"marshal object: %v"
,
err
)
}
}
url
:=
c
.
urlFor
(
apiVersion
,
namespace
,
resource
,
""
)
url
:=
c
li
.
urlFor
(
apiVersion
,
namespace
,
resource
,
""
)
resp
,
err
:=
c
.
client
.
Post
(
url
,
"application/json"
,
bytes
.
NewReader
(
body
))
resp
,
err
:=
c
li
.
client
.
Post
(
url
,
"application/json"
,
bytes
.
NewReader
(
body
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -196,13 +196,13 @@ func (c *client) postResource(apiVersion, namespace, resource string, v interfac
...
@@ -196,13 +196,13 @@ func (c *client) postResource(apiVersion, namespace, resource string, v interfac
return
checkHTTPErr
(
resp
,
http
.
StatusCreated
)
return
checkHTTPErr
(
resp
,
http
.
StatusCreated
)
}
}
func
(
c
*
client
)
delete
(
resource
,
name
string
)
error
{
func
(
c
li
*
client
)
delete
(
resource
,
name
string
)
error
{
url
:=
c
.
urlFor
(
c
.
apiVersion
,
c
.
namespace
,
resource
,
name
)
url
:=
c
li
.
urlFor
(
c
li
.
apiVersion
,
c
li
.
namespace
,
resource
,
name
)
req
,
err
:=
http
.
NewRequest
(
"DELETE"
,
url
,
nil
)
req
,
err
:=
http
.
NewRequest
(
"DELETE"
,
url
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"create delete request: %v"
,
err
)
return
fmt
.
Errorf
(
"create delete request: %v"
,
err
)
}
}
resp
,
err
:=
c
.
client
.
Do
(
req
)
resp
,
err
:=
c
li
.
client
.
Do
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"delete request: %v"
,
err
)
return
fmt
.
Errorf
(
"delete request: %v"
,
err
)
}
}
...
@@ -210,7 +210,7 @@ func (c *client) delete(resource, name string) error {
...
@@ -210,7 +210,7 @@ func (c *client) delete(resource, name string) error {
return
checkHTTPErr
(
resp
,
http
.
StatusOK
)
return
checkHTTPErr
(
resp
,
http
.
StatusOK
)
}
}
func
(
c
*
client
)
deleteAll
(
resource
string
)
error
{
func
(
c
li
*
client
)
deleteAll
(
resource
string
)
error
{
var
list
struct
{
var
list
struct
{
k8sapi
.
TypeMeta
`json:",inline"`
k8sapi
.
TypeMeta
`json:",inline"`
k8sapi
.
ListMeta
`json:"metadata,omitempty"`
k8sapi
.
ListMeta
`json:"metadata,omitempty"`
...
@@ -219,24 +219,24 @@ func (c *client) deleteAll(resource string) error {
...
@@ -219,24 +219,24 @@ func (c *client) deleteAll(resource string) error {
k8sapi
.
ObjectMeta
`json:"metadata,omitempty"`
k8sapi
.
ObjectMeta
`json:"metadata,omitempty"`
}
`json:"items"`
}
`json:"items"`
}
}
if
err
:=
c
.
list
(
resource
,
&
list
);
err
!=
nil
{
if
err
:=
c
li
.
list
(
resource
,
&
list
);
err
!=
nil
{
return
err
return
err
}
}
for
_
,
item
:=
range
list
.
Items
{
for
_
,
item
:=
range
list
.
Items
{
if
err
:=
c
.
delete
(
resource
,
item
.
Name
);
err
!=
nil
{
if
err
:=
c
li
.
delete
(
resource
,
item
.
Name
);
err
!=
nil
{
return
err
return
err
}
}
}
}
return
nil
return
nil
}
}
func
(
c
*
client
)
put
(
resource
,
name
string
,
v
interface
{})
error
{
func
(
c
li
*
client
)
put
(
resource
,
name
string
,
v
interface
{})
error
{
body
,
err
:=
json
.
Marshal
(
v
)
body
,
err
:=
json
.
Marshal
(
v
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"marshal object: %v"
,
err
)
return
fmt
.
Errorf
(
"marshal object: %v"
,
err
)
}
}
url
:=
c
.
urlFor
(
c
.
apiVersion
,
c
.
namespace
,
resource
,
name
)
url
:=
c
li
.
urlFor
(
c
li
.
apiVersion
,
c
li
.
namespace
,
resource
,
name
)
req
,
err
:=
http
.
NewRequest
(
"PUT"
,
url
,
bytes
.
NewReader
(
body
))
req
,
err
:=
http
.
NewRequest
(
"PUT"
,
url
,
bytes
.
NewReader
(
body
))
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"create patch request: %v"
,
err
)
return
fmt
.
Errorf
(
"create patch request: %v"
,
err
)
...
@@ -244,7 +244,7 @@ func (c *client) put(resource, name string, v interface{}) error {
...
@@ -244,7 +244,7 @@ func (c *client) put(resource, name string, v interface{}) error {
req
.
Header
.
Set
(
"Content-Length"
,
strconv
.
Itoa
(
len
(
body
)))
req
.
Header
.
Set
(
"Content-Length"
,
strconv
.
Itoa
(
len
(
body
)))
resp
,
err
:=
c
.
client
.
Do
(
req
)
resp
,
err
:=
c
li
.
client
.
Do
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"patch request: %v"
,
err
)
return
fmt
.
Errorf
(
"patch request: %v"
,
err
)
}
}
...
...
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