hwsc-org / hwsc-app-gateway-svc Goto Github PK
View Code? Open in Web Editor NEWWeb application gateway management service
Home Page: https://hwsc-org.github.io/hwsc-app-gateway-svc/
Web application gateway management service
Home Page: https://hwsc-org.github.io/hwsc-app-gateway-svc/
VerifyEmailToken service is used to verify that the user has entered a valid email address belonging to the user. It is used to validate users creating account for first time
and existing users wanting to update their email
.
token=someToken
gateway
using token authentication dial in the format of "authorization": "Email Token " + token
as metadata in the contextgateway
has to determine the token type (this is to differentiate between VerifyEmailToken
and VerifyAuthToken
gateway
will send this token to user-svc
VerifyEmailToken
VerifyEmailToken
will look up token in user_svc.email_tokens
tableuser_svc.email_tokens
tableuser_svc.accounts
table by looking up UUID grabbed from user_svc.email_tokens
is_verified
to TRUEuser_svc.email_tokens
tableuser_svc.accounts
table by looking up UUID grabbed from user_svc.email_tokens
tableuser_svc.email_tokens
prospective_email
column if its column is not null/emptyemail
column if prospective_email
column is null/emptyNote: For new users, if the token existed in the table but was expired, this means that the maintenance-svc
hasn't gotten around deleting the token and user from the database. We might as well re-use this information and allow new user to just click on a resent verification link??
As a developer, I want app-gateway-svc to handle refreshing invalid or missing auth secret
func init() {
userSvc = &userService{}
if err := refreshConnection(userSvc, consts.UserClientTag); err != nil {
// TODO once docker container is runnable
log.Error(consts.UserClientTag, err.Error())
//log.Fatal(consts.UserClientTag, err.Error())
}
// NOTE:
// app-gateway-svc does not start if all the services are not ready
// this is ONLY on app-gateway-svc startup
resp, err := userSvc.getStatus()
if err != nil {
// TODO once docker container is runnable
log.Error(consts.UserClientTag, err.Error())
//log.Fatal(consts.UserClientTag, err.Error())
} else {
log.Info(consts.UserClientTag, resp.String())
}
// TODO handle refreshing in case auth secret is missing
if err := userSvc.refreshCurrAuthSecret(); err != nil {
// NOTE: Check PSQL migration or if there is an active secret
log.Error(consts.UserClientTag, err.Error())
} else {
log.Info(consts.UserClientTag, "AuthSecret obtained")
}
// Handle Terminate Signal(Ctrl + C)
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
if err := disconnect(userSvc.userSvcConn, consts.UserClientTag); err != nil {
log.Error(consts.UserClientTag, err.Error())
}
log.Info(consts.UserClientTag, "hwsc-app-gateway-svc terminated")
serviceWg.Done()
}()
}
As a user, I want to be notified with the following:
Let us say Chrome wants to add a new document. At this point Chrome has the current User object, and it knows the user's uuid already.
image_urls_map, audio_urls_map, video_urls_map, & file_urls_map
are not filled up because there is no means of generating duid and fuids in the browser, therefore we have to send lists of urls.AddDocument()
with the followingmessage AppGatewayRequest{
hwsc.User user = N; //this is not a complete User object, it may only have uuid
hwsc.Document doc = N; //this is not a complete Document object, it may only have duid
repeated string image_urls = N;
repeated string audio_urls = N;
repeated string video_urls = N;
repeated string file_urls = N;
}
map<string, UserDocumentMetadata > user_documents = 7;
As a user, I want to login using email and password.
Epic: #23
As a DevOps, I want to deploy and to connect services using Docker or Kubernetes
hwsc-document-svc
hwsc-user-svc
hwsc-file-transaction-svc
hwsc-app-gateway-svc
hwsc-gateway-svc
& hwsc-user-svc
, hwsc-document-svc
, hwsc-file-transaction-svc
are communicating through hwsc-api-blocks
As a user, I want to be able register using my browser such as Chrome
Chrome wants to create a user.
userObject
- firstName: string
- lastName: string
- email: string
- password: hashed string
- organization: string
app-gateway-svc
CreateUser(userObject)
CreateUser(UserResponse)
app-gateway-svc
will call user-svc
GetStatus()
user-svc
:- Service is unavailable: return error with this message
- Service is available: proceed with the following
app-gateway-svc
will call user-svc
CreateUser(userObject)
user-svc
will take this userObject
and check if email already exists in mongoDB (unique email)- Email is taken: return error with this message
- Email not taken: proceed with the following
user-svc
will create a unique user ID using uliduser-svc
will hash the hashed password using bcryptuser-svc
will create and insert new document with userObject
information in user collection
user-svc
sends back OKapp-gateway-svc
receives any of the following message from user-svc
and sends it back to Chrome:1: Service is down
2: Email is taken
3: OK
1. If service is down: Chrome displays error message to user that service is unavailable atm and try again later
2. If email is taken: Chrome displays error message to user to use a different email
3. If OK: Chrome will redirect user to logged in search page
As a tester, when testing with MongoDB's, I want to be able to revert back to MongoDB's original state.
Copies of MongoDB's
As a developer using hwsc-app-gateway-svc, I need to know the services provided by hwsc-app-gateway-svc
As a developer, I want to integrate unit testing in the pipeline.
Enable client_hwsc_test.go
to test document-svc and file-transaction-svc
docker compose for document-svc and file-transaction-svc are currently disabled.
client_hwsc_test.go
As a developer, I want to return rpc code specific to the error to provide consistency in error decoding in front end and back end.
Requires refactoring everything that returns errors including unit tests and integration tests.
As a user, I want to configuration and environment variables to safely and securely run hwsc-app-gateway-svc
As a developer, I want to be able to send Chrome specific error messages to make it easier for it to determine the type of error to display to users.
TBD
The Chrome user has to be authenticated within hwsc
cluster.
For every single request within a cluster a token is passed for authorization.
app-gateway-svc
and user-svc
to DBapp-gateway-svc
, but not authorizedapp-gateway-svc
app-gateway-svc
app-gateway-svc
parses the header - DISCONNECTEDapp-gateway-svc
calls AuthenticateUser
from the user-svc
- DISCONNECTEDAuthenticaUser
returns code.Unauthenticated to app-gateway-svc
:app-gateway-svc
returns code.Unauthenticated to Chrome - DISCONNECTEDAuthenticateUser
returns code.Ok + Identification
to app-gateway-svc
, then app-gateway-svc
return code.Ok + token_string
as metadata in the context to Chrome - AUTHENTICATEDGetAuthToken
from app-gateway-svc
or parse the token_string
from the context's metadata.
token string
is defined below this documentGetAuthToken
from app-gateway-svc
with email and password -AUTHENTICATEDapp-gateway-svc
calls GetAuthToken
from user-svc
- AUTHENTICATEDuser-svc
validates from the DB. - AUTHENTICATEDuser-svc
returns code.Unauthenticated to app-gateway-svc
- AUTHENTICATEDapp-gateway-svc
returns code.Unauthenticated to Chrome - AUTHENTICATEDuser-svc
generates and returns Identification
, to `app-gateway-svc - AUTHORIZED
Identification
contains a Secret
and token string
user-svc
encodes the token string using hwsc-lib
NewToken
token string
expires in 2 hoursuser-svc
has to record everything in a DBapp-gateway-svc
returns the token string
to Chrome - AUTHORIZEDtoken_string
to authorized the actor or user - AUTHORIZEDhwsc-lib
to decode and validate the token string
, and if it is invalid would return code.Unauthenticated token string
is not expired using hwsc-lib
- AUTHORIZEDtoken string
is about to expire within 15 minutes, and calls GetToken
from app-gateway-svc
to get a new token. AUTHORIZEDtoken string
has expired, Chrome redirects to login page. DISCONNECTEDtoken string
is valid, services provide the appropriate RPC- AUTHORIZEDapp-gateway-svc
with token_string
from the Token
- DISCONNECTEDapp-gateway-svc
calls VerifyToken
from user-svc
- DISCONNECTEDuser-svc
verifies the token string
from DB - DISCONNECTEDtoken_string
is:
user-svc returns code.Unauthenticated to
app-gateway-svc` - DISCONNECTEDapp-gateway-svc
returns code.Unauthenticated to Chrome - DISCONNECTEDuser-svc
returns Identification
+ code.Ok to app-gateway-svc
AUTHORIZEDtoken string
, Identification
token string
is exchanged by Chrome and app-gateway-svc
struct Secret
contains string key
and created_timestamp
struct Identification
contains struct Secret
and token string
Identification
is utilized in the requests for user-svc
, document-svc
, and file-transaction-svc
Identification
is also returned in the response of user-svc
to app-gateway-svc
token string
expires in 2 hourstoken string
has 3 levels permission (feel free to add more)
USER
- can only perform CRUD on his/her own pageADMIN
- can perform CRUD with on any user's pagetoken_string
are the following:
HS256
HS512
JWT
"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJ1dWlkIjoiMTIzNDU2Nzg5MCIsInBlcm1pc3Npb24iOiJUb2tlbi5BRE1JTiIsImV4cGlyYXRpb25fdGltZSI6MTU0OTA5MzkxMH0.OZFQ_zU1F2BJm6kyYzsBns5qmOxbVbUnQV2SU1B_kyPfXPOmUd0fddRvF0I3IqaDz-55H7Q80w8zQyldMQ7AAg"
Secret
that contains the secret key as a string, and created date. and expiration date timestamp is required to generate a new secret key every week on Monday 3am Identification
will be defined in the api-blocks as a messageuser-svc
has to provide GetAuthToken
, VerifyAuthToken
, GetSecret
, MakeNewSecret
app-gateway-svc
has to implement BasicAuth
and TokenAuth
, and to provide GetAuthToken
Chrome wants to get the status of the app-gateway-svc
To know if Chrome can receive services from `app-gateway-svc
The current app-gateway-svc
states are the following:
app-gateway-svc
GetStatus
to confirm if service is reachable.app-gateway-svc
returns OK if app-gateway-svc
is available
.app-gateway-svc
returns UNAVAILABLE if app-gateway-svc
is unavailable
app-gateway-svc returns OK, Chrome will invoke services from
app-gateway-svc`.npm install
of hwsc-app-gateway-svc for hwsc-frontenddep ensure -v
or dep ensure -update
of hwsc-frontend "dist" for hwsc-app-gateway-svcAs a user, I want to be able to verify my email
As a user, I want to login using token.
Epic: #23
Chrome wants to get the following unique values for the following field names:
To generate available values to search.
Search Filter Page
rpc ListDistinctFieldValues (AppGatewayServiceRequest) returns (AppGatewayServiceResponse) {}
AppGatewayServiceRequest
rpc ListDistinctFieldValues (DocumentRequest) returns (DocumentResponse) {}
DocumentRequest
rpc ListDistinctFieldValues (DocumentRequest) returns (DocumentResponse) {}
rpc ListDistinctFieldValues (AppGatewayServiceRequest) returns (AppGatewayServiceResponse) {}
Status
or Message
OK
hwsc-frontend renders Search Filter Page
, else a default error page with error 500.As a dev, I want to localize all unit tests using containers
Containers for the following:
Let us say Chrome(User) wants to share a Document. At this point Chrome has the User object already.
message UserRequest {
User user = 1;
string duid = 2;
repeated string uuids_to_share_duid = 3;
}
map<string, UserDocumentMetadata > user_documents = 7
uuids_to_share_doc
in UserRequest.map<string, UserFriendMetadata> shared_to_me = 8
message User {
string uuid = 1;
string first_name = 2;
string last_name = 3;
string email = 4;
string password = 5;
string organization = 6;
// Key = duid in string
map<string, UserDocumentMetadata > user_documents = 7;
// Key = friend's uuid
map<string, UserFriendMetadata> shared_to_me = 8;
As a app-gateway-svc, I want to get/update the current auth Secret
GetSecret
to GetAuthSecret
MakeNewSecret
to MakeNewAuthSecret
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.