Categorygithub.com/hyperjumptech/hansip
module
1.0.0
Repository: https://github.com/hyperjumptech/hansip.git
Documentation: pkg.go.dev

# README

Hansip

An AAA (Access Authentication & Authorization) Service by Hyperjump

Building Hansip

Prerequisites:

  1. Golang 1.13
  2. Make utility

Step 1 Checkout and Install Go-Resource

$ git clone https://github.com/newm4n/go-resource.git
$ cd go-resource
$ go install

Step 2 Checkout Hansip

$ git clone https://github.com/hyperjumptech/hansip.git
$ cd hansip

Step 3 Build and Run

$ make build

Running the app will automatically build.

$ make run

Testing Hansip

$ make test

Configuring Hansip

If you want to run Hansip from the make file using make run command, you have to modify the environment variable in the run phase.

run: build
	export AAA_SERVER_HOST=localhost; \
	export AAA_SERVER_PORT=8088; \
	export AAA_SETUP_ADMIN_ENABLE=true; \
	./$(IMAGE_NAME).app
	rm -f $(IMAGE_NAME).app

You can change the import env variable.

If you're running from docker, you should modify the environment variable for the running image.

Environment Variable Values

VariableEnvironment VariableDefaultDescription
server.hostAAA_SERVER_HOSTlocalhostThe host name to bind. could be localhost or 0.0.0.0
server.portAAA_SERVER_PORT3000The host port to listen from
server.timeout.writeAAA_SERVER_TIMEOUT_WRITE15 secondsServer write timeout
server.timeout.readAAA_SERVER_TIMEOUT_READ15 secondsServer read timeout
server.timeout.idleAAA_SERVER_TIMEOUT_IDLE60 secondsServer connection IDLE timeout
server.timeout.graceshutAAA_SERVER_TIMEOUT_GRACESHUT15 secondsServer grace shutdown timeout
setup.admin.enableAAA_SETUP_ADMIN_ENABLEfalseEnable built in admin account
setup.admin.emailAAA_SETUP_ADMIN_EMAILadmin@hansipBuilt in admin email address for authentication
setup.admin.passphraseAAA_SETUP_ADMIN_PASSPHRASEthis must be change in the productionBuilt in admin password for authentication
token.issuerAAA_TOKE_ISSUERaaa.domain.comJWT Token issuer value
token.access.durationAAA_ACCESS_DURATION5 minutesJWT Access token lifetime
token.refresh.durationAAA_REFRESH_DURATION1 yearJWT Refresh token lifetime
token.crypt.keyAAA_TOKEN_CRYPT_KEYth15mustb3CH@ngedINprodUCT10NJWT token crypto key
token.crypt.methodAAA_TOKEN_CRYPT_METHODHS512JWT token crypto method
db.typeAAA_DB_TYPEINMEMORYDatabase type. INMEMORY or MYSQL
db.mysql.hostAAA_DB_MYSQL_HOSTlocalhostMySQL host
db.mysql.portAAA_DB_MYSQL_PORT3306MySQL Port
db.mysql.userAAA_DB_MYSQL_USERuserMySQL User to login
db.mysql.passwordAAA_DB_MYSQL_PASSWORDpasswordMySQL Password to login
db.mysql.databaseAAA_DB_MYSQL_DATABASEhansipMySQL Database to use
db.mysql.maxidleAAA_DB_MYSQL_MAXIDLE3Maximum connection that can IDLE
db.mysql.maxopenAAA_DB_MYSQL_MAXOPEN10Maximum open connection in the pool
mailer.typeAAA_MAILER_TYPEDUMMYMailer type. DUMMY or SENDMAIL
mailer.fromAAA_MAILER_FROM[email protected]The email from field
mailer.sendmail.hostAAA_MAILER_SENDMAIL_HOSTlocalhostMail server host
mailer.sendmail.portAAA_MAILER_SENDMAIL_PORT25Mail server port
mailer.sendmail.userAAA_MAILER_SENDMAIL_USERsendmailMail server user for authentication
mailer.sendmail.passwordAAA_MAILER_SENDMAIL_PASSWORDpasswordMail server password for authentication
mailer.templates.emailveri.subjectAAA_MAILER_TEMPLATES_EMAILVERI_SUBJECTPlease verify your new Hansip account's emailEmail verification subject template
mailer.templates.emailveri.bodyAAA_MAILER_TEMPLATES_EMAILVERI_BODY<html><body>Dear New Hansip User<br><br>Your new account is ready!<br>please click this <a href=\"http://hansip.io/activate?code={{.ActivationCode}}\">link to activate</a> your account.<br><br>Cordially,<br>HANSIP team</body></html>Email verification body template
mailer.templates.passrecover.subjectAAA_MAILER_TEMPLATES_PASSRECOVER_SUBJECTPassphrase recovery instructionPassword recovery email subject template
mailer.templates.passrecover.bodyAAA_MAILER_TEMPLATES_PASSRECOVER_BODY<html><body>Dear Hansip User<br><br>To recover your passphrase<br>please click this <a href=\"http://hansip.io/activate?code={{.RecoveryCode}}\">link to change your passphrase</a>.<br><br>Cordially,<br>HANSIP team</body></html>Password recovery email body template
server.http.cors.enableAAA_SERVER_HTTP_CORS_ENABLEtrueTo enable or disable CORS handling
server.http.cors.allow.originsAAA_SERVER_HTTP_CORS_ALLOW_ORIGINS*Indicates whether the response can be shared with requesting code from the given origin.
server.http.cors.allow.credentialAAA_SERVER_HTTP_CORS_ALLOW_CREDENTIALtrueresponse header tells browsers whether to expose the response to frontend JavaScript code when the request's credentials mode (Request.credentials) is include
server.http.cors.allow.methodAAA_SERVER_HTTP_CORS_ALLOW_METHODGET,PUT,DELETE,POST,OPTIONSresponse header specifies the method or methods allowed when accessing the resource in response to a preflight request.
server.http.cors.allow.headersAAA_SERVER_HTTP_CORS_ALLOW_HEADERSAccept,Authorization,Content-Type,X-CSRF-TOKEN,Accept-Encoding,X-Forwarded-For,X-Real-IP,X-Request-IDresponse header is used in response to a preflight request which includes the Access-Control-Request-Headers to indicate which HTTP headers can be used during the actual request.
server.http.cors.exposed.headersAAA_SERVER_HTTP_CORS_EXPOSED_HEADERS*response header indicates which headers can be exposed as part of the response by listing their names.
server.http.cors.optionpassthroughAAA_SERVER_HTTP_CORS_OPTIONPASSTHROUGHtrueIndicates that the OPTIONS method should be handled by server
server.http.cors.maxageAAA_SERVER_HTTP_CORS_MAXAGE300response header indicates how long the results of a preflight request (that is the information contained in the Access-Control-Allow-Methods and Access-Control-Allow-Headers headers) can be cached

API Doc

After you have run the server, you can access the API Doc at

http://localhost:3000/docs/

# Packages

No description provided by the author
No description provided by the author
No description provided by the author