Skip to content

GratitechInc/s3cr3tx

Repository files navigation

##############################################################################################################
##### s3cr3tx ReadMe File ####################################################################################
##### Author: Patrick Kelly ##################################################################################
##############################################################################################################
########Copyright 2022 Patrick Kelly and Gratitech Incorporated###############################################
##############################################################################################################
##### https://www.linkedin.com/in/PatrickAgileAppSecInfoSec ##################################################
##### https://www.GitHub.com/GratitechInc/s3cr3tx ######################################################
##### License: MIT License applies to the first 5 devices and first 2 developers #############################
##### Support, Maintenance and Software Assurance are available from Gratitech Incorporated ##################
##### https://Gratitech.com -> Products or email us at sales@gratitech.com ###################################
##############################################################################################################
# Pre-requisites:                                                                                            #
# 1.) .NET 7.0                                                                                               #
# 2.) SQL Server 2019 or above. It will work with SQL Server Express, Azure Sql Edge, and all other versions of SQL Server...
#     We recommend using it's own SQL Server & install on same server as the API   #
# 3.) Create a user on the host with SQL Server with the principle of least privilege                  	     #
# 4.) Update CreateS3cr3txLite.sql (T-SQL Script) with the user name from step 3.) above where s3cr3tus3r exists #
# 5.) Update Line 12 & 14 of CreateS3cr3txLite.sql (T-SQL Script) with the path for your DB files   	     #
##############################################################################################################
# Installation steps:											     #
# 1.) Run the script CreateS3cr3txLite.sql to create the Database                                                #
# 2.) Update connection strings for your environment & Build and Deploy the C# .NET 7.0 API project	     #
# 3.) Build/run/deploy the API using your favorite C# IDE (Visual Studio Community or Visual Studio Code will work!)
# 4.) Run the s3cr3tx api under the context of the user created in step 3.) of Pre-requisites above	     #
# 5.) Secure your s3cr3tx api with a strong TLS 1.2, 1.3 or stronger certificate and only allow HTTPS://     # 							  					     	     #
##############################################################################################################
# Usage instructions											     #
# 1.) Visit http://localhost:5039/swagger/index.html on the s3cr3tx_API server (or whatever URL fits your use case)                	             #
# 2.) submit your email address and two identical phrases in a json text input in the jsonString query string#
#	a.) jsonString format is: {"name":"sales@gratitech.com","pd":"abc123","pd2":"abc123"}
or Submit a curl to the deployment url like below:
curl -X 'POST' \
  'https://localhost:7192/Values?jsonString=%7B%22name%22%3A%22sales%40gratitech.com%22%2C%22pd%22%3A%22abc%22%2C%22pd2%22%3A%22abc%22%7D' \
  -H 'accept: text/plain' \
  -d ''	     #
# 3.) The response body includes your API-Key and AuthCode.  Please copy and save this information safely    #
# 4.) Use curl or the local version of the apps homepage to generate encrypted versions of the credentials to protect   #
# Curl (Windows) Example use ' (single quote) on linux instead: 											     #
curl -X "GET" https://localhost:7192/Values --header "accept: text/plain" --header "Email: sales@gratitech.com" --header "APIToken: wrxyw7HDm3vCv+KAugoKwrjLhsOHw6Nlw5AmecO94oCedlnCocOELFnCrGtUIcK/fsOQy4bDuuKAnVUETxLigKFTw5nLhsKrUFItMxfDgMOmFcONwrc8a8O4X8OFw5Ruwqo94oCZ" --header "AuthCode: w4Rrxb7DnRPCqDUAw6ljK8O9w4Zw4oCcNMOawqnDlcKzJR8zbsOlw7zDlFFKP1DCrRImdFVz4oCUw6nDggRSw45/KcKjw7dgYRd8GcK0xb7DlHrigLrCvMOvN1ZdSzo=" --header "EorD: E" --header "Input: Secr3tUs3rnameOrS3cr3tP@Ssw0rd" > output.text
# 5.) Store the encrypted versions of the credentials instead of the clear text versions using a function to #
#     call the s3cr3tx get method to decrypt the credentials in your code.  The get method requires 5 headers#
#    a.) the required headers are 1.) Email 2.) APIToken 3.) AuthCode 4.) EorD 5.) Input                     #
#    	1. Email: your email address that you created an APIToken and AuthCode with in step 2.)		     #
#       2. APIToken: the APIToken that was returned to you in step 2.)                                       #
#       3. AuthCode: the AuthCode that was returned to you in step 2.)					     #
#       4. EorD: use E as the value to encrypt the input or D as the value to decrypt the input 	     #
#       5. Input: the cleartext you want to encrypt or ciphertext you want to decrypt                        #
##############################################################################################################
########Copyright 2022 Patrick Kelly and Gratitech Incorporated###############################################
##############################################################################################################