-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multi-tenancy: Implements multi-tenancy
This commit implements multi-tenancy. DB resources _agent_ and _source_ have two additional columns: username and org_id. The _user_ struct is passed though the context to service layer by the auth middleware. Each service check if username is available in the context and use it to filter resources or to verify that the resource belongs to the user. Otherwise, it responds with 403. The buissness logic remains unchanged. There is no RBAC implemented in this commit (e.g. admin **sees** everything or only the user with _admin_ role has the right to access mutating endpoints). Adds: - filter by username to agent and source store. - mappers between api and models in the service layer. Modifies: Agent and source store interface are changed to accept models from the store instead of api's models. For example: ``` type Agent interface { ... Update(ctx context.Context, agentUpdate apiAgent.AgentStatusUpdate) (*api.Agent, error) ... } ``` is changed to ``` type Agent interface { ... Update(ctx context.Context, agent model.Agent) (*model.Agent, error) ... }``` A consequence of this is that mapping between API and DB models is made in the service layer with the help of `mappers`. Signed-off-by: Cosmin Tupangiu <[email protected]>
- Loading branch information
Showing
25 changed files
with
964 additions
and
331 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.