Skip to content

Commit

Permalink
Add 401 response (#13)
Browse files Browse the repository at this point in the history
* Switch to go modules
* Add utility function to get a 401 response object
* Typo
* Fix cloudbuild.yaml
  • Loading branch information
marcogschmidt authored and soloio-bulldozer[bot] committed Jan 14, 2020
1 parent af279cb commit 33a3e6a
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 265 deletions.
236 changes: 0 additions & 236 deletions Gopkg.lock

This file was deleted.

11 changes: 0 additions & 11 deletions Gopkg.toml

This file was deleted.

20 changes: 19 additions & 1 deletion api/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func AuthorizedResponse() *AuthorizationResponse {
}
}

// Minimal DENIED response
// Minimal FORBIDDEN (403) response
func UnauthorizedResponse() *AuthorizationResponse {
return &AuthorizationResponse{
CheckResponse: envoyauthv2.CheckResponse{
Expand All @@ -127,6 +127,24 @@ func UnauthorizedResponse() *AuthorizationResponse {
}
}

// Minimal UNAUTHORIZED (401) response
func UnauthenticatedResponse() *AuthorizationResponse {
return &AuthorizationResponse{
CheckResponse: envoyauthv2.CheckResponse{
Status: &status.Status{
Code: int32(codes.Unauthenticated),
},
HttpResponse: &envoyauthv2.CheckResponse_DeniedResponse{
DeniedResponse: &envoyauthv2.DeniedHttpResponse{
Status: &envoytype.HttpStatus{
Code: envoytype.StatusCode_Unauthorized,
},
},
},
},
}
}

func InternalServerErrorResponse() *AuthorizationResponse {
resp := UnauthorizedResponse()
resp.CheckResponse.HttpResponse = &envoyauthv2.CheckResponse_DeniedResponse{
Expand Down
6 changes: 6 additions & 0 deletions changelog/v0.1.2/add-unauthenticated-response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: NEW_FEATURE
description: Add a utility function to get a basic `401 Unauthorized` response.
issueLink: https://github.com/solo-io/ext-auth-plugins/issues/12
- type: NON_USER_FACING
description: Switch to [Go Modules](https://blog.golang.org/using-go-modules) to manage dependencies.
19 changes: 2 additions & 17 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
steps:
# Using dep container from github.com/solo-io/cloud-builders/dep
# This copies files into the proper workspace layout and so must be run before other tasks.
# Subsequent steps must set the $GOPATH env variable.
- name: 'gcr.io/$PROJECT_ID/dep'
id: 'dep'
args: ['ensure']
env:
- 'PROJECT_ROOT=github.com/solo-io/ext-auth-plugins'

- name: 'gcr.io/$PROJECT_ID/ginkgo:0.1.12'
- name: 'gcr.io/$PROJECT_ID/go-mod-ginkgo:0.2.1'
id: 'test'
args: ['-r']
env:
- 'PROJECT_ROOT=github.com/solo-io/ext-auth-plugins'
- 'GOPATH=/workspace/gopath'
- 'TAGGED_VERSION=$TAG_NAME'
- 'BUILD_ID=$BUILD_ID'
dir: './gopath/src/github.com/solo-io/ext-auth-plugins'
args: ['-r']
20 changes: 20 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module github.com/solo-io/ext-auth-plugins

go 1.13

require (
github.com/envoyproxy/go-control-plane v0.9.0
github.com/envoyproxy/protoc-gen-validate v0.1.0
github.com/golang/protobuf v1.3.2
github.com/hpcloud/tail v1.0.1-0.20180514194441-a1dbeea552b7
github.com/onsi/ginkgo v1.7.0
github.com/onsi/gomega v1.4.3
golang.org/x/net v0.0.0-20190611141213-3f473d35a33a
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
golang.org/x/text v0.3.0
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55
google.golang.org/grpc v1.23.0
gopkg.in/fsnotify/fsnotify.v1 v1.4.7
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
gopkg.in/yaml.v2 v2.2.1
)
Loading

0 comments on commit 33a3e6a

Please sign in to comment.