Skip to content

Commit

Permalink
chore: SSO improvement feature requires Enterprise Edition. (#10124)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreyaLnuHpe authored Oct 24, 2024
1 parent c71617c commit a84f8c6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions master/internal/api_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,26 @@ import (
"github.com/determined-ai/determined/master/internal/api"
"github.com/determined-ai/determined/master/internal/db"
"github.com/determined-ai/determined/master/internal/grpcutil"
"github.com/determined-ai/determined/master/internal/license"
"github.com/determined-ai/determined/master/internal/token"
"github.com/determined-ai/determined/master/pkg/model"
"github.com/determined-ai/determined/proto/pkg/apiv1"
)

var errAccessTokenRequiresEE = status.Error(
codes.FailedPrecondition,
"users cannot log in with an access token without a valid Enterprise Edition license set up.",
)

// PostAccessToken takes user id and optional lifespan, description and creates an
// access token for the given user.
func (a *apiServer) PostAccessToken(
ctx context.Context, req *apiv1.PostAccessTokenRequest,
) (*apiv1.PostAccessTokenResponse, error) {
if !license.IsEE() {
return nil, errAccessTokenRequiresEE
}

curUser, _, err := grpcutil.GetUser(ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -58,6 +68,10 @@ func (a *apiServer) PostAccessToken(
func (a *apiServer) GetAccessTokens(
ctx context.Context, req *apiv1.GetAccessTokensRequest,
) (*apiv1.GetAccessTokensResponse, error) {
if !license.IsEE() {
return nil, errAccessTokenRequiresEE
}

curUser, _, err := grpcutil.GetUser(ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -161,6 +175,10 @@ func (a *apiServer) GetAccessTokens(
func (a *apiServer) PatchAccessToken(
ctx context.Context, req *apiv1.PatchAccessTokenRequest,
) (*apiv1.PatchAccessTokenResponse, error) {
if !license.IsEE() {
return nil, errAccessTokenRequiresEE
}

curUser, _, err := grpcutil.GetUser(ctx)
if err != nil {
return nil, err
Expand Down

0 comments on commit a84f8c6

Please sign in to comment.