project.go 529 B

12345678910111213141516171819202122
  1. package auth
  2. import (
  3. "context"
  4. "net/http"
  5. "github.com/porter-dev/porter/api/types"
  6. )
  7. func NewProjectContext(ctx context.Context, project types.Project) context.Context {
  8. return context.WithValue(ctx, types.ProjectScope, project)
  9. }
  10. func ProjectScoped(h http.Handler, w http.ResponseWriter, r *http.Request) {
  11. // read the project id from the request
  12. // find a set of roles for this user and compute a policy document
  13. // determine if policy document allows for project scope
  14. // create a new project-scoped context
  15. }