-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1262 from pkulik0/CSS-9387-add-rebac-admin-backen…
…d-server Css 9387 add rebac admin backend server
- Loading branch information
Showing
8 changed files
with
126 additions
and
7 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
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,19 @@ | ||
// Copyright 2024 Canonical Ltd. | ||
|
||
package rebac_admin | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/canonical/rebac-admin-ui-handlers/v1/interfaces" | ||
) | ||
|
||
type Authenticator struct{} | ||
|
||
var _ interfaces.Authenticator = &Authenticator{} | ||
|
||
// Authenticate extracts the calling user's information from the given HTTP request | ||
func (a *Authenticator) Authenticate(r *http.Request) (any, error) { | ||
// TODO(CSS-9386): replace with real authentication | ||
return "joe", nil | ||
} |
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,24 @@ | ||
package rebac_admin | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/canonical/jimm/internal/errors" | ||
rebachandlers "github.com/canonical/rebac-admin-ui-handlers/v1" | ||
"github.com/juju/zaputil/zapctx" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func SetupBackend(ctx context.Context) (*rebachandlers.ReBACAdminBackend, error) { | ||
const op = errors.Op("setupRebacBackend") | ||
|
||
rebacBackend, err := rebachandlers.NewReBACAdminBackend(rebachandlers.ReBACAdminBackendParams{ | ||
Authenticator: &Authenticator{}, | ||
}) | ||
if err != nil { | ||
zapctx.Error(ctx, "failed to create rebac admin backend", zap.Error(err)) | ||
return nil, errors.E(op, err, "failed to create rebac admin backend") | ||
} | ||
|
||
return rebacBackend, nil | ||
} |
Oops, something went wrong.