Skip to content

Commit

Permalink
Release v2.0.2 (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
shurwit committed Aug 18, 2022
2 parents f41c983 + 396d233 commit 24e01c6
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 83 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Go

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

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

- name: Test
run: go test -v ./...
20 changes: 15 additions & 5 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
},
{
"path": "detect_secrets.filters.regex.should_exclude_file",
"pattern": [
"go.sum"
]
}
],
"results": {
Expand All @@ -100,14 +106,16 @@
"filename": "authutils/utils_test.go",
"hashed_secret": "db3c13e7fbe7d15476af52cb1d419aa66c406759",
"is_verified": false,
"line_number": 70
"line_number": 70,
"is_secret": false
},
{
"type": "Hex High Entropy String",
"filename": "authutils/utils_test.go",
"hashed_secret": "244f421f896bdcdd2784dccf4eaf7c8dfd5189b5",
"is_verified": false,
"line_number": 71
"line_number": 71,
"is_secret": false
}
],
"internal/testutils/test_utils.go": [
Expand All @@ -116,7 +124,8 @@
"filename": "internal/testutils/test_utils.go",
"hashed_secret": "be4fc4886bd949b369d5e092eb87494f12e57e5b",
"is_verified": false,
"line_number": 59
"line_number": 59,
"is_secret": false
}
],
"sigauth/signature_test.go": [
Expand All @@ -125,9 +134,10 @@
"filename": "sigauth/signature_test.go",
"hashed_secret": "560d8afec04521a86978c49f5b05961e40fd6a35",
"is_verified": false,
"line_number": 368
"line_number": 368,
"is_secret": false
}
]
},
"generated_at": "2022-06-09T20:09:26Z"
"generated_at": "2022-08-16T16:45:18Z"
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [2.0.2] - 2022-08-18
### Added
- Automate tests [#4](https://github.com/rokwire/core-auth-library-go/issues/4)
### Changed
- Expose Request parsing functions [#65](https://github.com/rokwire/core-auth-library-go/issues/65)

## [2.0.1] - 2022-06-15
### Changed
- Update documentation [#62](https://github.com/rokwire/core-auth-library-go/issues/62)
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Patches for **Core Auth Library** in this repository will only be applied to the following versions:
| Version | Supported |
| ------- | ------------------ |
| 2.0.1 | :white_check_mark: |
| < 2.0.1 | :x: |
| 2.0.2 | :white_check_mark: |
| < 2.0.2 | :x: |

## Reporting a Bug or Vulnerability

Expand Down
30 changes: 19 additions & 11 deletions authservice/auth_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
"sync"
Expand Down Expand Up @@ -136,7 +136,8 @@ func (s *ServiceRegManager) GetServiceRegWithPubKey(id string) (*ServiceReg, err
}

// LoadServices loads the subscribed service registration records and caches them
// This function will be called periodically after refreshCacheFreq, but can be called directly to force a cache refresh
//
// This function will be called periodically after refreshCacheFreq, but can be called directly to force a cache refresh
func (s *ServiceRegManager) LoadServices() error {
services, loadServicesError := s.loader.LoadServices()
if services != nil {
Expand All @@ -151,6 +152,7 @@ func (s *ServiceRegManager) SubscribedServices() []string {
}

// SubscribeServices subscribes to the provided services
//
// If reload is true and one of the services is not already subscribed, the service registrations will be reloaded immediately
func (s *ServiceRegManager) SubscribeServices(serviceIDs []string, reload bool) error {
newSub := false
Expand Down Expand Up @@ -212,15 +214,17 @@ func (s *ServiceRegManager) ValidateServiceRegistrationKey(privKey *rsa.PrivateK
}

// SetMinRefreshCacheFreq sets the minimum frequency at which cached service registration records are refreshed in minutes
// The default value is 1
//
// The default value is 1
func (s *ServiceRegManager) SetMinRefreshCacheFreq(freq uint) {
s.servicesLock.Lock()
s.minRefreshCacheFreq = freq
s.servicesLock.Unlock()
}

// SetMaxRefreshCacheFreq sets the maximum frequency at which cached service registration records are refreshed in minutes
// The default value is 60
//
// The default value is 60
func (s *ServiceRegManager) SetMaxRefreshCacheFreq(freq uint) {
s.servicesLock.Lock()
if freq >= s.minRefreshCacheFreq {
Expand Down Expand Up @@ -339,7 +343,7 @@ type ServiceRegLoader interface {
UnsubscribeService(serviceID string) bool
}

//RemoteServiceRegLoaderImpl provides a ServiceRegLoader implementation for a remote auth service
// RemoteServiceRegLoaderImpl provides a ServiceRegLoader implementation for a remote auth service
type RemoteServiceRegLoaderImpl struct {
authService *AuthService
client *http.Client
Expand Down Expand Up @@ -373,7 +377,7 @@ func (r *RemoteServiceRegLoaderImpl) LoadServices() ([]ServiceReg, error) {

defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("error reading body of service response: %v", err)
}
Expand Down Expand Up @@ -419,7 +423,8 @@ func NewRemoteServiceRegLoader(authService *AuthService, subscribedServices []st
// -------------------- ServiceRegSubscriptions --------------------

// ServiceRegSubscriptions defined a struct to hold service registration subscriptions
// This struct implements the subcription part of the ServiceRegManager interface
//
// This struct implements the subcription part of the ServiceRegManager interface
// If you subscribe to the reserved "all" service ID, all registered services
// will be loaded
type ServiceRegSubscriptions struct {
Expand All @@ -436,7 +441,8 @@ func (r *ServiceRegSubscriptions) GetSubscribedServices() []string {
}

// SubscribeService adds the given service ID to the list of subscribed services if not already present
// Returns true if the specified service was added or false if it was already found
//
// Returns true if the specified service was added or false if it was already found
func (r *ServiceRegSubscriptions) SubscribeService(serviceID string) bool {
r.servicesLock.Lock()
defer r.servicesLock.Unlock()
Expand All @@ -450,7 +456,8 @@ func (r *ServiceRegSubscriptions) SubscribeService(serviceID string) bool {
}

// UnsubscribeService removed the given service ID from the list of subscribed services if presents
// Returns true if the specified service was removed or false if it was not found
//
// Returns true if the specified service was removed or false if it was not found
func (r *ServiceRegSubscriptions) UnsubscribeService(serviceID string) bool {
r.servicesLock.Lock()
defer r.servicesLock.Unlock()
Expand Down Expand Up @@ -613,7 +620,8 @@ func (s *ServiceAccountManager) AppOrgPairs() []AppOrgPair {
}

// SetMaxRefreshCacheFreq sets the maximum frequency at which cached access tokens are refreshed in minutes
// The default value is 30
//
// The default value is 30
func (s *ServiceAccountManager) SetMaxRefreshCacheFreq(freq uint) {
s.tokensLock.Lock()
s.maxRefreshCacheFreq = freq
Expand Down Expand Up @@ -854,7 +862,7 @@ type ServiceAccountLoader interface {
LoadAccessTokens() (map[AppOrgPair]AccessToken, error)
}

//RemoteServiceAccountLoaderImpl provides a ServiceAccountLoader implementation for a remote auth service
// RemoteServiceAccountLoaderImpl provides a ServiceAccountLoader implementation for a remote auth service
type RemoteServiceAccountLoaderImpl struct {
authService *AuthService
client *http.Client
Expand Down
7 changes: 4 additions & 3 deletions authutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
)

Expand All @@ -37,7 +37,8 @@ func ContainsString(slice []string, val string) bool {
}

// RemoveString removes the provided value from the provided slice
// Returns modified slice. If val is not found returns unmodified slice
//
// Returns modified slice. If val is not found returns unmodified slice
func RemoveString(slice []string, val string) ([]string, bool) {
for i, other := range slice {
if other == val {
Expand Down Expand Up @@ -105,7 +106,7 @@ func ReadResponseBody(resp *http.Response) ([]byte, error) {

defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("error reading response body: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions authutils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"crypto/rsa"
"encoding/hex"
"fmt"
"io/ioutil"
"io"
"net/http"
"reflect"
"strings"
Expand Down Expand Up @@ -176,8 +176,8 @@ func TestGetPubKeyPem(t *testing.T) {
}

func TestReadResponseBody(t *testing.T) {
unauthorized := &http.Response{StatusCode: http.StatusUnauthorized, Status: fmt.Sprintf("%d %s", http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized)), Body: ioutil.NopCloser(strings.NewReader("test"))}
ok := &http.Response{StatusCode: http.StatusOK, Status: fmt.Sprintf("%d %s", http.StatusOK, http.StatusText(http.StatusOK)), Body: ioutil.NopCloser(strings.NewReader("test"))}
unauthorized := &http.Response{StatusCode: http.StatusUnauthorized, Status: fmt.Sprintf("%d %s", http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized)), Body: io.NopCloser(strings.NewReader("test"))}
ok := &http.Response{StatusCode: http.StatusOK, Status: fmt.Sprintf("%d %s", http.StatusOK, http.StatusText(http.StatusOK)), Body: io.NopCloser(strings.NewReader("test"))}

type args struct {
resp *http.Response
Expand Down
4 changes: 2 additions & 2 deletions example/signature/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"

Expand Down Expand Up @@ -85,7 +85,7 @@ func (we WebAdapter) sampleSignedRequest(url string, param string, body []byte)
return "", fmt.Errorf("error from sample request: %d - %s", resp.StatusCode, resp.Body)
}

response, err := ioutil.ReadAll(resp.Body)
response, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("error reading body of sample response: %v", err)
}
Expand Down
32 changes: 22 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
module github.com/rokwire/core-auth-library-go/v2

go 1.16
go 1.18

require (
github.com/aws/aws-sdk-go v1.39.4
github.com/casbin/casbin/v2 v2.31.10
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/golang-jwt/jwt v3.2.1+incompatible
github.com/aws/aws-sdk-go v1.44.77
github.com/casbin/casbin/v2 v2.51.2
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/rokwire/logging-library-go v1.0.3
github.com/stretchr/testify v1.8.0
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
gopkg.in/go-playground/validator.v9 v9.31.0
)

require (
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/rokwire/logging-library-go v1.0.0
github.com/stretchr/objx v0.1.1 // indirect
github.com/stretchr/testify v1.6.1
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/stretchr/objx v0.4.0 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/validator.v9 v9.31.0
gopkg.in/yaml.v3 v3.0.1 // indirect
)

0 comments on commit 24e01c6

Please sign in to comment.