-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement TFE API for Team Tokens (#624)
Towards #580 This is the initial API implementation for Team Tokens. The TFE integration tests pass, but I don't think the token can actually be used to do anything as yet. I've added `Team` as a sort of half-concept for the RBAC. It's not a full category in it's own right, but uses the `User` team memberships to authorize. Not sure if that's desirable, but it seemed a minimal effort fit as I understand how the RBAC works. --------- Co-authored-by: Louis Garman <louisgarman@gmail.com>
- Loading branch information
1 parent
76e7dda
commit 1e4b173
Showing
28 changed files
with
836 additions
and
130 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package auth | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/go-logr/logr" | ||
"github.com/leg100/otf/internal" | ||
"github.com/leg100/otf/internal/rbac" | ||
) | ||
|
||
// Authorizer authorizes access to a team | ||
type Authorizer struct { | ||
logr.Logger | ||
} | ||
|
||
func (a *Authorizer) CanAccess(ctx context.Context, action rbac.Action, teamID string) (internal.Subject, error) { | ||
subj, err := internal.SubjectFromContext(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if subj.CanAccessTeam(action, teamID) { | ||
return subj, nil | ||
} | ||
a.Error(nil, "unauthorized action", "team_id", teamID, "action", action.String(), "subject", subj) | ||
return nil, internal.ErrAccessNotPermitted | ||
} |
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
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
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
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
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
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
Oops, something went wrong.