-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding horusec auth base project * Adding auth handler, with auth types enum and credetials * Finishing handlers and adding auth controller with factory by type * Change filter to receive Severity and remove Type * Adding missing unity tests in devkit * Adding auth handler tests * Adding swagger, updating router and configs * Fixing lint and tests * Adding horus service authenticate method * Adding authorize handler * Updating auth interface * Adding postgres read * Adding keycloak service auth and keycloak shared service * Adding unit test * Adding horusec roles enum * Fixing return * Adding validation to authorize by horus roles * Renaming packges to horusec * Fixing some horusec name errors and unity tests * Removing nolint and improving code * Renaming file to horusec * Adding create user from keycloak token * Adding create user from keycloak token * Adding create user from keycloak token * Adding horusec service unity testes * Adding auth controller unity tests and updating mocks * Adding auth in compose and fixing docs * Adding auth in compose and fixing docs * Updating health check * Fixing lint * Fixing keycloak unity tests * Adding unit tests * Adding unit tests * Updating middlewares to use auth service * Fixing auth type * Fixing tests fmt lint * Fixing tests fmt lint * Fixing Security * Improving code and adding unity tests * Adding more devkit unity tests * Adding some unit tests * Adding middleware service unity tests * Removing unnecessary test * Adding horusec auth readme * Fixing dockerfiles * Adding validation to actual auth type * Removing auth type header * Updating composes * Removing groups from authorization data * Updating account, api and analytic readme * Updating compose with auth url env var * Updating compose and compose dev * Fixing unity tests and fmt errors * Fixing auth pipeline and hashes false positives * Fixing error that token was static to accept only jwt * Addding role validation in keycloak * Fixing token size and swagger error * Removing bearer from keycloak token * Adding api to get account id by token and auth type * Chaging create account from keycloak to auth * Updating auth swagger * Improving keycloak devkit service and fixing tests * Fixing account unity tests * Fixing account unity tests in auth * Adding auth unity tests * Fixing middleware tests * Fixing fmt error * Improving interface convertion to avoid conversion error Co-authored-by: Wilian Gabriel <wilian.silva@zup.com.br>
- Loading branch information
1 parent
3bf7a2b
commit 5c6cbce
Showing
2,208 changed files
with
7,772 additions
and
1,042,323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: HorusecAuthPipeline | ||
|
||
on: | ||
push: | ||
branches: [ "master", "develop" ] | ||
pull_request: | ||
branches: [ "**" ] | ||
|
||
jobs: | ||
install-build-test-fmt-lint: | ||
name: install-build-test-fmt-lint | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, '[skip ci]')" | ||
steps: | ||
- name: Set up Go 1.14 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.14 | ||
id: go | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Setup External Dependences | ||
run: COMPOSE_FILE_NAME="docker-compose.test.yaml" make compose | ||
- name: fmt | ||
run: | | ||
echo "==> Checking that code complies with gofmt requirements..." | ||
gofmt_files=$(gofmt -l `find ./horusec-auth -name '*.go' | grep -v vendor`) | ||
echo $gofmt_files | ||
if [ ! -z $gofmt_files ]; then | ||
echo 'gofmt needs running on the following files:' | ||
echo "$gofmt_files" | ||
echo "You can use the command: \`gofmt -w \$(gofmt -l \'find ./horusec-auth -name \'*.go\' | grep -v vendor)\` to reformat code." | ||
exit 1 | ||
fi | ||
echo "=) The project horusec-auth it's OK!" | ||
- name: lint | ||
run: | | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.25.0 | ||
./bin/golangci-lint run -v --timeout=2m -c .golangci.yml ./horusec-auth/... | ||
- name: test | ||
run: | | ||
go clean -testcache | ||
go test -v ./horusec-auth/... -timeout=2m -parallel=1 -failfast -short | ||
- name: coverage | ||
run: make coverage-horusec-auth | ||
- name: build | ||
run: go build -o "./tmp/bin/horusec-auth" ./horusec-auth/cmd/app/main.go | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 20 additions & 10 deletions
30
...rocfs/internal/util/sysreadfile_compat.go → ...it/pkg/entities/account/keycloak_token.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,36 @@ | ||
// Copyright 2019 The Prometheus Authors | ||
// Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// +build linux,appengine !linux | ||
|
||
package util | ||
package account | ||
|
||
import ( | ||
"fmt" | ||
"encoding/json" | ||
|
||
validation "github.com/go-ozzo/ozzo-validation/v4" | ||
) | ||
|
||
// SysReadFile is here implemented as a noop for builds that do not support | ||
// the read syscall. For example Windows, or Linux on Google App Engine. | ||
func SysReadFile(file string) (string, error) { | ||
return "", fmt.Errorf("not supported on this platform") | ||
type KeycloakToken struct { | ||
AccessToken string `json:"accessToken"` | ||
} | ||
|
||
func (l *KeycloakToken) Validate() error { | ||
return validation.ValidateStruct(l, | ||
validation.Field(&l.AccessToken, validation.Required), | ||
) | ||
} | ||
|
||
func (l *KeycloakToken) ToBytes() []byte { | ||
bytes, _ := json.Marshal(l) | ||
return bytes | ||
} |
39 changes: 39 additions & 0 deletions
39
development-kit/pkg/entities/account/keycloak_token_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package account | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestKeycloakTokenToBytes(t *testing.T) { | ||
t.Run("should success parse to bytes", func(t *testing.T) { | ||
keyCloakToken := &KeycloakToken{} | ||
assert.NotEmpty(t, keyCloakToken.ToBytes()) | ||
}) | ||
} | ||
|
||
func TestKeycloakTokenValidate(t *testing.T) { | ||
t.Run("should return no error when not empty", func(t *testing.T) { | ||
keyCloakToken := &KeycloakToken{AccessToken: "test"} | ||
assert.NoError(t, keyCloakToken.Validate()) | ||
}) | ||
|
||
t.Run("should return error when empty access token", func(t *testing.T) { | ||
keyCloakToken := &KeycloakToken{} | ||
assert.Error(t, keyCloakToken.Validate()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.