You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment in hs_hub, the hub has its own login and team system. We need to remove this and replace it with API calls to hs_auth.
We need to change a few systems in the hub:
Login system
First, look at src/util/user/passportLocalStrategy.ts. This uses a LocalStrategy in passportjs. Basically, it takes the username and passport from the request so they can be used for authentication.
We need to replace it with a "cookie strategy" (look at hs_application: src/util/auth/hs_auth for details on implementation). You can also refer to the passport js docs under "custom callback". The hub will perform exactly the same authentication flow as the applications so you can almost copy/paste the code.
In the hub (src/util/user/authorization.ts) we have define some middleware we use to check that:
A user is logged in
They have the required authentication level
We need to replace this with the code from hs_application. It will probably be very similar so you can again just follow how it works in hs_application (we have it all in a single file src/util/auth/hs_auth.ts).
If you could update the file structure in hs_hub to match that of hs_hub for these methods that would be great 😊
Team system
This one might be a bit more difficult, the team system on the hub needs to be refactored to use the hs_auth team API. Most of the work will be done in src/services/teams/teamsService.ts. When they click "Profile" on the Hub we should make API calls to get the users team and when they edit some info (like join/leave teams) we should make an API call to hs_auth to perform these actions. Here is a postman link to a collect where you can find the API endpoints. I have included them below for quick reference as well:
Create team -> POST /api/v1/teams with name in the body of the request
Get teams -> GET /api/v1/teams
Leave team -> DELETE /api/v1/teams/leave
Join team -> POST /api/v1/teams/<team id>/join
Get team members -> GET /api/v1/teams/<team id>/members
Each of the API requests needs the auth token in the Authorization header. You can see an example of it in hs_application: src/util/auth/hs_auth.ts (around line 70).
The text was updated successfully, but these errors were encountered:
At the moment in hs_hub, the hub has its own login and team system. We need to remove this and replace it with API calls to hs_auth.
We need to change a few systems in the hub:
Login system
First, look at
src/util/user/passportLocalStrategy.ts
. This uses a LocalStrategy in passportjs. Basically, it takes the username and passport from the request so they can be used for authentication.We need to replace it with a "cookie strategy" (look at hs_application:
src/util/auth/hs_auth
for details on implementation). You can also refer to the passport js docs under "custom callback". The hub will perform exactly the same authentication flow as the applications so you can almost copy/paste the code.In the hub (
src/util/user/authorization.ts
) we have define some middleware we use to check that:We need to replace this with the code from hs_application. It will probably be very similar so you can again just follow how it works in hs_application (we have it all in a single file
src/util/auth/hs_auth.ts
).If you could update the file structure in hs_hub to match that of hs_hub for these methods that would be great 😊
Team system
This one might be a bit more difficult, the team system on the hub needs to be refactored to use the hs_auth team API. Most of the work will be done in
src/services/teams/teamsService.ts
. When they click "Profile" on the Hub we should make API calls to get the users team and when they edit some info (like join/leave teams) we should make an API call to hs_auth to perform these actions. Here is a postman link to a collect where you can find the API endpoints. I have included them below for quick reference as well:POST /api/v1/teams
with name in the body of the requestGET /api/v1/teams
DELETE /api/v1/teams/leave
POST /api/v1/teams/<team id>/join
GET /api/v1/teams/<team id>/members
Each of the API requests needs the auth token in the
Authorization
header. You can see an example of it inhs_application: src/util/auth/hs_auth.ts (around line 70)
.The text was updated successfully, but these errors were encountered: