Skip to content

Commit e9e8934

Browse files
authored
Merge pull request #126 from ARGOeu/devel
Version 0.1.5
2 parents b880518 + 305f931 commit e9e8934

File tree

11 files changed

+51
-24
lines changed

11 files changed

+51
-24
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ Before you start, you need to issue a valid certificate.
3232

3333
4. Get dependencies(If you plan on contributing to the project else skip this step):
3434

35-
Argo-api-authN uses the dep tool for dependency handling.
35+
Argo-api-authN uses the go modules tool for dependency handling.
3636

37-
- Install the dep tool. You can find instructions depending on your platform at [Dep](https://github.com/golang/dep).
38-
3937
5. To build the service use the following command:
4038

4139
`go build`
@@ -83,7 +81,8 @@ Before you start, you need to issue a valid certificate.
8381
"service_types_retrieval_fields": {
8482
"ams": "token",
8583
"web-api": "api_key"
86-
}
84+
},
85+
"syslog_enabled": true
8786
}
8887
```
8988

argo-api-authn.spec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
Name: argo-api-authn
55
Summary: ARGO Authentication API. Map X509, OICD to token.
6-
Version: 0.1.4
6+
Version: 0.1.5
77
Release: 1%{?dist}
88
License: ASL 2.0
99
Buildroot: %{_tmppath}/%{name}-buildroot
@@ -57,6 +57,8 @@ go clean
5757
%attr(0644,root,root) /usr/lib/systemd/system/argo-api-authn.service
5858

5959
%changelog
60+
* Wed Nov 18 2020 Agelos Tsalapatis <agelos.tsal@gmail .com> - 0.1.5-1%{?dist}
61+
- Release of argo-api-authn version 0.1.5
6062
* Thu Jun 13 2019 Agelos Tsalapatis <agelos.tsal@gmail.com> - 0.1.4-1%{?dist}
6163
- Release of argo-api-authn version 0.1.4
6264
* Thu Jun 13 2019 Agelos Tsalapatis <agelos.tsal@gmail.com> - 0.1.3-1%{?dist}

auth/revoke.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package auth
33
import (
44
"crypto/x509"
55
"crypto/x509/pkix"
6+
"fmt"
67
"github.com/ARGOeu/argo-api-authn/utils"
78
LOGGER "github.com/sirupsen/logrus"
89
"io/ioutil"
@@ -17,7 +18,7 @@ func CRLCheckRevokedCert(cert *x509.Certificate) error {
1718

1819
var err error
1920
var goMaxP, psi, csi int
20-
var crtList *pkix.TBSCertificateList
21+
var crtList pkix.TBSCertificateList
2122
var errChan = make(chan error)
2223
var doneChan = make(chan bool, 1)
2324

@@ -118,30 +119,37 @@ loop:
118119
}
119120

120121
// FetchCRL fetches the CRL
121-
func FetchCRL(url string) (*pkix.TBSCertificateList, error) {
122+
func FetchCRL(url string) (pkix.TBSCertificateList, error) {
122123

123124
var err error
124-
var crtList *pkix.CertificateList
125125
var resp *http.Response
126126
var crlBytes []byte
127127

128+
var crtList = &pkix.CertificateList{}
129+
128130
// initialize the client and perform a get request to grab the crl
129-
client := &http.Client{Timeout: time.Duration(60 * time.Second)}
131+
client := &http.Client{Timeout: time.Duration(30 * time.Second)}
130132
if resp, err = client.Get(url); err != nil {
131-
return &crtList.TBSCertList, err
133+
LOGGER.Error(fmt.Errorf("Request to CRL: %v produced the following error, %v", url, err.Error()))
134+
err := fmt.Errorf("Could not access CRL %v", url)
135+
return pkix.TBSCertificateList{}, err
132136
}
133137

134138
// read the response
135139
if crlBytes, err = ioutil.ReadAll(resp.Body); err != nil {
136-
return &crtList.TBSCertList, err
140+
err := fmt.Errorf("Reading CRL data: %v produced the following error, %v", url, err.Error())
141+
LOGGER.Error(err)
142+
return pkix.TBSCertificateList{}, err
137143
}
138144

139145
defer resp.Body.Close()
140146

141147
// create the crl from the byte slice
142148
if crtList, err = x509.ParseCRL(crlBytes); err != nil {
143-
return &crtList.TBSCertList, err
149+
err := fmt.Errorf("Parsing CRL data: %v produced the following error, %v", url, err.Error())
150+
LOGGER.Error(err)
151+
return pkix.TBSCertificateList{}, err
144152
}
145153

146-
return &crtList.TBSCertList, err
154+
return crtList.TBSCertList, err
147155
}

auth/revoke_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package auth
33
import (
44
"crypto/x509"
55
"encoding/pem"
6+
LOGGER "github.com/sirupsen/logrus"
67
"github.com/stretchr/testify/suite"
8+
"io/ioutil"
79
"testing"
810
)
911

@@ -124,8 +126,16 @@ func (suite *RevokeTestSuite) TestCRLCheckRevokedCert() {
124126
err3 := CRLCheckRevokedCert(crt)
125127

126128
suite.Equal("Your certificate is invalid. No CRLDistributionPoints found on the certificate", err3.Error())
129+
130+
// test the case of an invalid CRL URL
131+
crt = ParseCert(goodComodoCA)
132+
crt.CRLDistributionPoints = []string{"https://unknown/unknown"}
133+
err4 := CRLCheckRevokedCert(crt)
134+
135+
suite.Equal("Could not access CRL https://unknown/unknown", err4.Error())
127136
}
128137

129138
func TestRevokeTestSuite(t *testing.T) {
139+
LOGGER.SetOutput(ioutil.Discard)
130140
suite.Run(t, new(RevokeTestSuite))
131141
}

authmethods/authmethods_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/stretchr/testify/suite"
88
"io"
99
"io/ioutil"
10-
"reflect"
1110
"testing"
1211
)
1312

@@ -149,7 +148,8 @@ func (suite *AuthMethodsTestSuite) TestAuthMethodFIndAll() {
149148
mockstore.AuthMethods = []stores.QAuthMethod{}
150149
aMList2, err2 := AuthMethodFindAll(mockstore)
151150

152-
suite.True(reflect.DeepEqual(expAmList, aMList))
151+
suite.Equal(am1, aMList.AuthMethods[0])
152+
suite.Equal(am2, aMList.AuthMethods[1])
153153
suite.Equal(0, len(aMList2.AuthMethods))
154154

155155
suite.Nil(err1)

conf/argo-api-authn-config.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"trust_unknown_cas": true,
1414
"verify_certificate": false,
1515
"service_types_paths": {"ams": "/v1/users:byUUID/{{identifier}}?key={{access_key}}"},
16-
"service_types_retrieval_fields": {"ams": "token"}
16+
"service_types_retrieval_fields": {"ams": "token"},
17+
"syslog_enabled": false
1718
}

config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"service_types_retrieval_fields": {
2020
"ams": "token",
2121
"web-api": "api_key"
22-
}
22+
},
23+
"syslog_enabled" : false
2324
}

config/config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"errors"
77
"github.com/ARGOeu/argo-api-authn/utils"
88
LOGGER "github.com/sirupsen/logrus"
9+
lSyslog "github.com/sirupsen/logrus/hooks/syslog"
910
"io/ioutil"
11+
"log/syslog"
1012
"reflect"
1113
)
1214

@@ -26,6 +28,7 @@ type Config struct {
2628
VerifyCertificate bool `json:"verify_certificate"`
2729
ServiceTypesPaths map[string]string `json:"service_types_paths" required:"true"`
2830
ServiceTypesRetrievalFields map[string]string `json:"service_types_retrieval_fields" required:"true"`
31+
SyslogEnabled bool `json:"syslog_enabled"`
2932
}
3033

3134
// ConfigSetUp unmarshals a json file specified by the input parameter into the config object
@@ -42,6 +45,13 @@ func (cfg *Config) ConfigSetUp(path string) error {
4245
return errors.New("Something went wrong while marshaling the json data. Error: " + err.Error())
4346
}
4447

48+
if cfg.SyslogEnabled {
49+
hook, err := lSyslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
50+
if err == nil {
51+
LOGGER.AddHook(hook)
52+
}
53+
}
54+
4555
if err = utils.ValidateRequired(*cfg); err != nil {
4656
return utils.StructGenericEmptyRequiredField("config", err.Error())
4757
}

config/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func (suite *ConfigTestSuite) TestConfigSetUp() {
4242
"ams": "token",
4343
"web-api": "api_key",
4444
},
45+
SyslogEnabled: true,
4546
}
4647

4748
//tests the case of a malformed json

config/configuration-test-files/test-conf.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"service_types_retrieval_fields": {
2020
"ams": "token",
2121
"web-api": "api_key"
22-
}
22+
},
23+
"syslog_enabled": true
2324
}

0 commit comments

Comments
 (0)