Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sectigo Staging Service #917

Merged
merged 8 commits into from
Nov 30, 2022
Merged

Sectigo Staging Service #917

merged 8 commits into from
Nov 30, 2022

Conversation

bbengfort
Copy link
Collaborator

@bbengfort bbengfort commented Nov 29, 2022

Scope of changes

Adds a mock Sectigo service with a self-signed CA that we can use for integration testing to ensure that the GDS interacts with Sectigo appropriately. This will allow us to "issue" certs and download them from GDS without using our Sectigo licenses.

Fixes SC-8965

Type of change

  • bug fix
  • new feature
  • documentation
  • other (staging service)

Acceptance criteria

This is quite a big PR - so a cursory review is fine.

Author checklist

  • I have manually tested the change and/or added automation in the form of unit tests or integration tests
  • I have updated the dependencies list
  • I have recompiled and included new protocol buffers to reflect changes I made
  • I have added new test fixtures as needed to support added tests
  • Check this box if a reviewer can merge this pull request after approval (leave it unchecked if you want to do it yourself)
  • I have moved the associated Shortcut story to "Ready for Review"

Reviewer(s) checklist

  • Any new user-facing content that has been added for this PR has been QA'ed to ensure correct grammar, spelling, and understandability.

c.Next()
}

// Token time constraint constants.
Copy link
Collaborator Author

@bbengfort bbengfort Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple JWT authentication using HS512 signed JWT tokens and a random key that is generated every time the server starts. This mimics the Sectigo API directly.

@@ -0,0 +1,110 @@
package server
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains all the "Sectigo" endpoints.

}

// Generate a new self-signed certificate to issue certs
template := &x509.Certificate{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a self-signed CA cert isn't specified, one is generated.

return nil
}

func (c AuthConfig) ParseSecret() []byte {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a secret isn't specified, one is generated.

@bbengfort bbengfort marked this pull request as ready for review November 29, 2022 22:32
@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2022

Codecov Report

Base: 44.38% // Head: 43.87% // Decreases project coverage by -0.50% ⚠️

Coverage data is based on head (30ff7c5) compared to base (6a4efdd).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #917      +/-   ##
==========================================
- Coverage   44.38%   43.87%   -0.51%     
==========================================
  Files         680      687       +7     
  Lines       24509    25449     +940     
  Branches     1548     1548              
==========================================
+ Hits        10878    11167     +289     
- Misses      12241    12847     +606     
- Partials     1390     1435      +45     
Flag Coverage Δ
unittests 43.87% <ø> (-0.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ub.com/trisacrypto/directory/pkg/sectigo/config.go 66.66% <0.00%> (-33.34%) ⬇️
...b.com/trisacrypto/directory/pkg/sectigo/sectigo.go 42.74% <0.00%> (-0.42%) ⬇️
...hub.com/trisacrypto/directory/pkg/sectigo/creds.go 43.44% <0.00%> (ø)
...m/trisacrypto/directory/pkg/sectigo/serializers.go 0.00% <0.00%> (ø)
.../trisacrypto/directory/pkg/sectigo/server/store.go 10.16% <0.00%> (ø)
...trisacrypto/directory/pkg/sectigo/server/server.go 78.94% <0.00%> (ø)
...trisacrypto/directory/pkg/sectigo/server/status.go 26.66% <0.00%> (ø)
...com/trisacrypto/directory/pkg/sectigo/server/ca.go 0.00% <0.00%> (ø)
...trisacrypto/directory/pkg/sectigo/server/config.go 25.75% <0.00%> (ø)
.../trisacrypto/directory/pkg/sectigo/server/certs.go 47.36% <0.00%> (ø)
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@pdeziel pdeziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've completed a quick review, not really in depth but the overall approach seems good and will definitely be useful for integration testing!

pkg/sectigo/sectigo.go Show resolved Hide resolved
}

if _, err = s.tokens.Verify(string(token)); err != nil {
fmt.Println(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was left in from debugging?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch; thanks!

const (
accessTokenDuration = 1 * time.Hour
refreshTokenDuration = 2 * time.Hour
accessRefreshOverlap = -1 * time.Hour
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, the accessRefreshOverlap specifies the duration for which the access token and refresh token are both valid?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct; normally it's -15 minutes but for testing the -1 hour overlaps the access token duration completely.

@bbengfort bbengfort merged commit 937898f into main Nov 30, 2022
@bbengfort bbengfort deleted the staging-sectigo branch November 30, 2022 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants