Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pam/internal/adapter/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,13 @@ func (m authenticationModel) Update(msg tea.Msg) (authModel authenticationModel,

switch msg.access {
case auth.Granted:
return m, sendEvent(PamSuccess{BrokerID: m.currentBrokerID, msg: authMsg})
var secret string
if msg.secret != nil {
secret = *msg.secret
} else {
log.Warningf(context.Background(), "authentication granted, but no secret returned, cannot set PAM_AUTHTOK")
}
return m, sendEvent(PamSuccess{BrokerID: m.currentBrokerID, AuthTok: secret, msg: authMsg})

case auth.Retry:
m.errorMsg = authMsg
Expand Down
1 change: 1 addition & 0 deletions pam/internal/adapter/return.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type PamReturnError interface {
// PamSuccess signals PAM module to return with provided pam.Success and Quit tea.Model.
type PamSuccess struct {
BrokerID string
AuthTok string
msg string
}

Expand Down
5 changes: 5 additions & 0 deletions pam/pam.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ func (h *pamModule) handleAuthRequest(mode authd.SessionMode, mTx pam.ModuleTran
if err := mTx.SetData(authenticationBrokerIDKey, exitStatus.BrokerID); err != nil {
return err
}
if exitStatus.AuthTok != "" {
if err := mTx.SetItem(pam.Authtok, exitStatus.AuthTok); err != nil {
return err
}
}
return nil

case adapter.PamReturnError:
Expand Down
Loading