Skip to content

Commit

Permalink
Merge pull request #8 from openfort-xyz/feat/encryption-sessions
Browse files Browse the repository at this point in the history
Feat/encryption sessions
  • Loading branch information
gllm-dev authored Jul 11, 2024
2 parents e7eb1b7 + d32d103 commit a8ec245
Show file tree
Hide file tree
Showing 112 changed files with 2,132 additions and 1,239 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
!go.mod
!.golangci.yml
!Dockerfile
!CHANGELOG.md
!.github/workflows/run-rests.yml
!.github/workflows/docker-image.yml

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

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.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.1.11]
### Added
- Encryption Sessions, allow projects to register a on time use session with an encryption part to encrypt/decrypt a secret.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.0-alpine as builder
FROM golang:1.22.5-alpine as builder
RUN apk add --no-cache ca-certificates
WORKDIR /app
COPY . .
Expand All @@ -8,5 +8,5 @@ FROM scratch
WORKDIR /app
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/app /usr/bin/
COPY internal/infrastructure/repositories/sql/migrations /app/internal/infrastructure/repositories/sql/migrations
COPY internal/adapters/repositories/sql/migrations /app/internal/adapters/repositories/sql/migrations
ENTRYPOINT ["app"]
2 changes: 1 addition & 1 deletion cmd/cli/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cli
import (
"github.com/spf13/cobra"
"go.openfort.xyz/shield/di"
"go.openfort.xyz/shield/internal/infrastructure/repositories/sql"
"go.openfort.xyz/shield/internal/adapters/repositories/sql"
)

func NewCmdDB() *cobra.Command {
Expand Down
77 changes: 57 additions & 20 deletions di/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@ package di

import (
"github.com/google/wire"
"go.openfort.xyz/shield/internal/adapters/authenticators"
"go.openfort.xyz/shield/internal/adapters/authenticators/identity"
"go.openfort.xyz/shield/internal/adapters/authenticators/identity/openfort_identity"
"go.openfort.xyz/shield/internal/adapters/encryption"
"go.openfort.xyz/shield/internal/adapters/handlers/rest"
"go.openfort.xyz/shield/internal/adapters/repositories/bunt"
"go.openfort.xyz/shield/internal/adapters/repositories/bunt/encryptionpartsrepo"
"go.openfort.xyz/shield/internal/adapters/repositories/sql"
"go.openfort.xyz/shield/internal/adapters/repositories/sql/projectrepo"
"go.openfort.xyz/shield/internal/adapters/repositories/sql/providerrepo"
"go.openfort.xyz/shield/internal/adapters/repositories/sql/sharerepo"
"go.openfort.xyz/shield/internal/adapters/repositories/sql/userrepo"
"go.openfort.xyz/shield/internal/applications/projectapp"
"go.openfort.xyz/shield/internal/applications/shareapp"
"go.openfort.xyz/shield/internal/core/ports/factories"
"go.openfort.xyz/shield/internal/core/ports/repositories"
"go.openfort.xyz/shield/internal/core/ports/services"
"go.openfort.xyz/shield/internal/core/services/projectsvc"
"go.openfort.xyz/shield/internal/core/services/providersvc"
"go.openfort.xyz/shield/internal/core/services/sharesvc"
"go.openfort.xyz/shield/internal/core/services/usersvc"
"go.openfort.xyz/shield/internal/infrastructure/authenticationmgr"
"go.openfort.xyz/shield/internal/infrastructure/handlers/rest"
"go.openfort.xyz/shield/internal/infrastructure/providersmgr"
"go.openfort.xyz/shield/internal/infrastructure/repositories/sql"
"go.openfort.xyz/shield/internal/infrastructure/repositories/sql/projectrepo"
"go.openfort.xyz/shield/internal/infrastructure/repositories/sql/providerrepo"
"go.openfort.xyz/shield/internal/infrastructure/repositories/sql/sharerepo"
"go.openfort.xyz/shield/internal/infrastructure/repositories/sql/userrepo"
)

func ProvideSQL() (c *sql.Client, err error) {
Expand All @@ -32,6 +37,14 @@ func ProvideSQL() (c *sql.Client, err error) {
return
}

func ProvideBuntDB() (c *bunt.Client, err error) {
wire.Build(
bunt.New,
)

return
}

func ProvideSQLUserRepository() (r repositories.UserRepository, err error) {
wire.Build(
userrepo.New,
Expand Down Expand Up @@ -68,6 +81,15 @@ func ProvideSQLShareRepository() (r repositories.ShareRepository, err error) {
return
}

func ProvideInMemoryEncryptionPartsRepository() (r repositories.EncryptionPartsRepository, err error) {
wire.Build(
encryptionpartsrepo.New,
ProvideBuntDB,
)

return
}

func ProvideProjectService() (s services.ProjectService, err error) {
wire.Build(
projectsvc.New,
Expand Down Expand Up @@ -95,20 +117,21 @@ func ProvideUserService() (s services.UserService, err error) {
return
}

func ProvideShareService() (s services.ShareService, err error) {
func ProvideEncryptionFactory() (f factories.EncryptionFactory, err error) {
wire.Build(
sharesvc.New,
ProvideSQLShareRepository,
encryption.NewEncryptionFactory,
ProvideInMemoryEncryptionPartsRepository,
ProvideSQLProjectRepository,
)

return
}

func ProvideProviderManager() (pm *providersmgr.Manager, err error) {
func ProvideShareService() (s services.ShareService, err error) {
wire.Build(
providersmgr.NewManager,
providersmgr.GetConfigFromEnv,
ProvideSQLProviderRepository,
sharesvc.New,
ProvideSQLShareRepository,
ProvideEncryptionFactory,
)

return
Expand All @@ -120,6 +143,7 @@ func ProvideShareApplication() (a *shareapp.ShareApplication, err error) {
ProvideShareService,
ProvideSQLShareRepository,
ProvideSQLProjectRepository,
ProvideEncryptionFactory,
)

return
Expand All @@ -133,17 +157,28 @@ func ProvideProjectApplication() (a *projectapp.ProjectApplication, err error) {
ProvideProviderService,
ProvideSQLProviderRepository,
ProvideSQLShareRepository,
ProvideEncryptionFactory,
ProvideInMemoryEncryptionPartsRepository,
)

return
}

func ProvideAuthenticationManager() (am *authenticationmgr.Manager, err error) {
func ProvideAuthenticationFactory() (f factories.AuthenticationFactory, err error) {
wire.Build(
authenticationmgr.NewManager,
ProvideSQLProjectRepository,
ProvideProviderManager,
authenticators.NewAuthenticatorFactory,
ProvideUserService,
ProvideSQLProjectRepository,
)

return
}

func ProvideIdentityFactory() (f factories.IdentityFactory, err error) {
wire.Build(
identity.NewIdentityFactory,
ofidty.GetConfigFromEnv,
ProvideSQLProviderRepository,
)

return
Expand All @@ -155,7 +190,9 @@ func ProvideRESTServer() (s *rest.Server, err error) {
rest.GetConfigFromEnv,
ProvideShareApplication,
ProvideProjectApplication,
ProvideAuthenticationManager,
ProvideUserService,
ProvideAuthenticationFactory,
ProvideIdentityFactory,
)

return
Expand Down
107 changes: 81 additions & 26 deletions di/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a8ec245

Please sign in to comment.