Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 35 additions & 36 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,50 @@ name: Go

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build
run: go build -race -v ./...

- name: Test
run: |
go test -race -cover -coverprofile ./coverage.out.tmp ./...
cat ./coverage.out.tmp | grep -v '.pb.go' | grep -v 'mock_' > ./coverage.out
rm ./coverage.out.tmp

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41.1

- name: Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go

- name: Build
run: go build -race -v ./...

- name: Test
run: |
go test -race -cover -coverprofile ./coverage.out.tmp ./...
cat ./coverage.out.tmp | grep -v '.pb.go' | grep -v 'mock_' > ./coverage.out
rm ./coverage.out.tmp

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: latest
skip-cache: true

- name: Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out

finish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
vendor/

*.swp

*.go_
155 changes: 81 additions & 74 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,97 +1,104 @@
run:
concurrency: 4
deadline: 1m
issues-exit-code: 1
tests: false
skip-files:
- ".*_mock\\.go"
- "mock_.*\\.go"
- ".*/pkg/mod/.*$"

output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true

linters-settings:
errcheck:
check-type-assertions: false
check-blank: false
govet:
check-shadowing: false
revive:
ignore-generated-header: true
severity: warning
gofmt:
simplify: true
gocyclo:
min-complexity: 18
maligned:
suggest-new: true
dupl:
threshold: 50
goconst:
min-len: 3
min-occurrences: 2
depguard:
list-type: blacklist
include-go-root: false
packages:
- github.com/davecgh/go-spew/spew
misspell:
locale: US
ignore-words:
- cancelled
goimports:
local-prefixes: go.opentelemetry.io


linters:
disable-all: true
formatters:
enable:
- deadcode
- depguard
- errcheck
- gas
- goconst
- gocyclo
- gofmt
- revive
- govet
- ineffassign
- megacheck
- misspell
- structcheck
- typecheck
- unconvert
- varcheck
- gosimple
- staticcheck
- unused
exclusions:
paths:
- .*_mock\.go
- mock_.*\.go
- .*/pkg/mod/.*$
- .*/go/src/.*\.go
- third_party$
- builtin$
- examples$
settings:
gofmt:
simplify: true
goimports:
local-prefixes:
- go.opentelemetry.io
issues:
max-issues-per-linter: 50
linters:
default: none
enable:
- asciicheck
- bodyclose
- dogsled
- dupl
- durationcheck
- errcheck
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- goconst
- gocritic
- gocyclo
- godot
- goerr113
- gosec
- ifshort
- govet
- ineffassign
- misspell
- nestif
- nilerr
- nlreturn
- noctx
- prealloc
- predeclared
- revive
- sqlclosecheck
- tagliatelle
- staticcheck
- unconvert
- unused
- whitespace
- wrapcheck
- wsl
fast: false
exclusions:
paths:
- .*_mock\.go
- mock_.*\.go
- .*/pkg/mod/.*$
- .*/go/src/.*\.go
- third_party$
- builtin$
- examples$
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
settings:
depguard:
rules:
main:
allow:
- $all
dupl:
threshold: 99
errcheck:
check-blank: false
check-type-assertions: false
goconst:
min-len: 3
min-occurrences: 2
gocyclo:
min-complexity: 18
govet:
disable:
- shadow
misspell:
ignore-rules:
- cancelled
locale: US
revive:
severity: warning
output:
formats:
text:
path: stdout
print-issued-lines: true
print-linter-name: true
run:
concurrency: 4
issues-exit-code: 1
tests: false
version: "2"
2 changes: 1 addition & 1 deletion authentication/credential/username_password_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type UsernamePasswordCredential struct {
var _ Credential = (*UsernamePasswordCredential)(nil)

// NewUsernamePasswordCredential constructor.
func NewUsernamePasswordCredential(principal string, credentials string) Credential {
func NewUsernamePasswordCredential(principal string, credentials string) *UsernamePasswordCredential {
return &UsernamePasswordCredential{
credentials: credentials,
principal: principal,
Expand Down
1 change: 1 addition & 0 deletions authentication/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

// Provider Service interface for encoding passwords
//
//go:generate mockery --name=Provider --inpackage --case underscore
type Provider interface {
Authenticate(r *http.Request, creds credential.Credential) (*http.Request, error)
Expand Down
1 change: 1 addition & 0 deletions authentication/provider/dao/dao_authentication_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (p *DaoAuthenticationProvider) Authenticate(r *http.Request, creds credenti
return r, ErrBadAuthenticationFormat
}

// nolint:forcetypeassert
u, err := p.userProvider.LoadUserByUsername(auth.GetPrincipal().(string))
if err != nil {
return r, fmt.Errorf("user provider failed: %w", err)
Expand Down
1 change: 1 addition & 0 deletions authentication/provider/dao/user_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package dao
import "github.com/hyperscale-stack/security/user"

// UserProvider interface which loads user-specific data.
//
//go:generate mockery --name=UserProvider --inpackage --case underscore
type UserProvider interface {
LoadUserByUsername(username string) (user.User, error)
Expand Down
Loading