Skip to content

Commit ecf7ff4

Browse files
committed
fixes
Signed-off-by: Grant Linville <grant@acorn.io>
1 parent 502b578 commit ecf7ff4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pkg/jwt/persistent/persistent.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ type TokenService struct {
3030
gatewayClient *client.Client
3131
credOnlyGPTClient *gptscript.GPTScript
3232
serverURL string
33+
authEnabled bool
3334
}
3435

35-
func NewTokenService(serverURL string, gatewayClient *client.Client, credOnlyGPTClient *gptscript.GPTScript) (*TokenService, error) {
36+
func NewTokenService(serverURL string, gatewayClient *client.Client, credOnlyGPTClient *gptscript.GPTScript, authEnabled bool) (*TokenService, error) {
3637
t := &TokenService{
3738
gatewayClient: gatewayClient,
3839
credOnlyGPTClient: credOnlyGPTClient,
3940
serverURL: serverURL,
41+
authEnabled: authEnabled,
4042
}
4143
return t, nil
4244
}
@@ -201,9 +203,14 @@ func (t *TokenService) AuthenticateRequest(req *http.Request) (*authenticator.Re
201203
},
202204
}, true, nil
203205
default:
206+
uid := tokenContext.AuthProviderUserID
207+
if !t.authEnabled {
208+
uid = tokenContext.UserID
209+
}
210+
204211
return &authenticator.Response{
205212
User: &user.DefaultInfo{
206-
UID: tokenContext.AuthProviderUserID,
213+
UID: uid,
207214
Name: tokenContext.UserName,
208215
Groups: tokenContext.UserGroups,
209216
Extra: map[string][]string{

pkg/services/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ func New(ctx context.Context, config Config) (*Services, error) {
462462
return nil, err
463463
}
464464

465-
persistentTokenServer, err := persistent.NewTokenService(config.Hostname, gatewayClient, credOnlyGPTscriptClient)
465+
persistentTokenServer, err := persistent.NewTokenService(config.Hostname, gatewayClient, credOnlyGPTscriptClient, config.EnableAuthentication)
466466
if err != nil {
467467
return nil, fmt.Errorf("failed to setup persistent token service: %w", err)
468468
}

0 commit comments

Comments
 (0)