-
Notifications
You must be signed in to change notification settings - Fork 699
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
Added env based support for HTTPS connection #4706
Merged
Saranya-jena
merged 25 commits into
litmuschaos:master
from
Saranya-jena:encryption-fixes
Jul 8, 2024
Merged
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
0a19e54
Added env based support for HTTPS connection
Saranya-jena 76345b2
Merge branch 'master' into encryption-fixes
Saranya-jena 330ec52
resolved review comments
Saranya-jena 336665c
Merge branch 'encryption-fixes' of https://github.com/Saranya-jena/li…
Saranya-jena 149c387
Merge branch 'master' into encryption-fixes
namkyu1999 a9736c7
updated logic
Saranya-jena 1d6eb99
Merge branch 'encryption-fixes' of https://github.com/Saranya-jena/li…
Saranya-jena 710cb04
fixed importd
Saranya-jena f999601
added helper files
Saranya-jena 13ec01c
resolved comments
Saranya-jena e9f6c01
resolved comments
Saranya-jena f32a433
Update push.yml
Saranya-jena 12acd13
minor changes
Saranya-jena 2979e72
Merge branch 'encryption-fixes' of https://github.com/Saranya-jena/li…
Saranya-jena 708c787
minor changes
Saranya-jena 187a959
minor changes
Saranya-jena 9eadda5
minor changes
Saranya-jena 70b280c
minor changes
Saranya-jena 14796a4
Update push.yml
Saranya-jena 53228c0
updated branch
Saranya-jena cc8f811
Merge branch 'encryption-fixes' of https://github.com/Saranya-jena/li…
Saranya-jena 0cedfc6
updated branch
Saranya-jena f479270
updated oush.yam
Saranya-jena 2240e1e
Merge branch 'master' of https://github.com/litmuschaos/litmus into e…
Saranya-jena 427c364
updated manifest
Saranya-jena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,8 +3,10 @@ package main | |||||
import ( | ||||||
"flag" | ||||||
"fmt" | ||||||
"google.golang.org/grpc/credentials" | ||||||
"net" | ||||||
"runtime" | ||||||
"strconv" | ||||||
"time" | ||||||
|
||||||
grpcHandler "github.com/litmuschaos/litmus/chaoscenter/authentication/api/handlers/grpc" | ||||||
|
@@ -114,7 +116,21 @@ func main() { | |||||
|
||||||
validatedAdminSetup(applicationService) | ||||||
|
||||||
go runGrpcServer(applicationService) | ||||||
enableHTTPSConnection, err := strconv.ParseBool(utils.EnableHTTPSConnection) | ||||||
if err != nil { | ||||||
log.Errorf("unable to parse boolean value %v", err) | ||||||
} | ||||||
|
||||||
if enableHTTPSConnection { | ||||||
if utils.CustomTlsCert != "" && utils.TlSKey != "" { | ||||||
go runGrpcServerWithTLS(applicationService) | ||||||
} else { | ||||||
log.Fatalf("Failure to start chaoscenter authentication REST server due to empty TLS cert file path and TLS key path") | ||||||
} | ||||||
} else { | ||||||
go runGrpcServer(applicationService) | ||||||
} | ||||||
|
||||||
runRestServer(applicationService) | ||||||
} | ||||||
|
||||||
|
@@ -172,10 +188,27 @@ func runRestServer(applicationService services.ApplicationService) { | |||||
routes.ProjectRouter(app, applicationService) | ||||||
routes.CapabilitiesRouter(app) | ||||||
|
||||||
log.Infof("Listening and serving HTTP on %s", utils.Port) | ||||||
err := app.Run(utils.Port) | ||||||
enableHTTPSConnection, err := strconv.ParseBool(utils.EnableHTTPSConnection) | ||||||
if err != nil { | ||||||
log.Fatalf("Failure to start litmus-portal authentication REST server due to %v", err) | ||||||
log.Errorf("unable to parse boolean value %v", err) | ||||||
} | ||||||
|
||||||
if enableHTTPSConnection { | ||||||
if utils.CustomTlsCert != "" && utils.TlSKey != "" { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can rename it wrt |
||||||
log.Infof("Listening and serving HTTPS on %s", utils.Port) | ||||||
err := app.RunTLS(utils.Port, utils.CustomTlsCert, utils.TlSKey) | ||||||
if err != nil { | ||||||
log.Fatalf("Failure to start litmus-portal authentication REST server due to %v", err) | ||||||
} | ||||||
} else { | ||||||
log.Fatalf("Failure to start chaoscenter authentication REST server due to empty TLS cert file path and TLS key path") | ||||||
} | ||||||
} else { | ||||||
log.Infof("Listening and serving HTTP on %s", utils.Port) | ||||||
err := app.Run(utils.Port) | ||||||
if err != nil { | ||||||
log.Fatalf("Failure to start litmus-portal authentication REST server due to %v", err) | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -195,3 +228,27 @@ func runGrpcServer(applicationService services.ApplicationService) { | |||||
log.Fatalf("Failure to start litmus-portal authentication GRPC server due to %v", err) | ||||||
} | ||||||
} | ||||||
|
||||||
func runGrpcServerWithTLS(applicationService services.ApplicationService) { | ||||||
// Starting gRPC server | ||||||
lis, err := net.Listen("tcp", utils.GrpcPort) | ||||||
if err != nil { | ||||||
log.Fatalf("Failure to start litmus-portal authentication server due to %s", err) | ||||||
} | ||||||
|
||||||
// Load TLS credentials | ||||||
creds, err := credentials.NewServerTLSFromFile(utils.CustomTlsCert, utils.TlSKey) | ||||||
if err != nil { | ||||||
log.Fatalf("failed to create credentials: %v", err) | ||||||
} | ||||||
|
||||||
grpcApplicationServer := grpcHandler.ServerGrpc{ApplicationService: applicationService} | ||||||
grpcServer := grpc.NewServer(grpc.Creds(creds)) | ||||||
grpcPresenter.RegisterAuthRpcServiceServer(grpcServer, &grpcApplicationServer) | ||||||
|
||||||
log.Infof("Listening and serving gRPC on %s with TLS", utils.GrpcPort) | ||||||
err = grpcServer.Serve(lis) | ||||||
if err != nil { | ||||||
log.Fatalf("Failure to start litmus-portal authentication GRPC server due to %v", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.