Update auth service for portal OAuth logins
Create IAM sessions from OAuth callbacks with the portal hostname and consent data needed by the compliance portal API. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -68,6 +68,7 @@ type (
|
||||
Continue *string
|
||||
// If users tries to connect to compliance page, we must brand the emails accordingly
|
||||
CompliancePageID *gid.GID
|
||||
MagicLinkBaseURL *string
|
||||
}
|
||||
|
||||
PasswordResetData struct {
|
||||
@@ -460,12 +461,22 @@ func (s AuthService) OpenSessionWithSAML(ctx context.Context, identityID gid.GID
|
||||
}
|
||||
|
||||
func (s AuthService) OpenSessionWithOIDC(ctx context.Context, identityID gid.GID, authMethod coredata.AuthMethod) (*coredata.Session, error) {
|
||||
return s.OpenRootSession(ctx, identityID, authMethod, coredata.SessionData{})
|
||||
}
|
||||
|
||||
func (s AuthService) OpenRootSession(
|
||||
ctx context.Context,
|
||||
identityID gid.GID,
|
||||
authMethod coredata.AuthMethod,
|
||||
data coredata.SessionData,
|
||||
) (*coredata.Session, error) {
|
||||
session := &coredata.Session{}
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Tx) (err error) {
|
||||
session = coredata.NewRootSession(identityID, authMethod, s.sessionDuration)
|
||||
session.Data = data
|
||||
|
||||
err = session.Insert(ctx, conn)
|
||||
if err != nil {
|
||||
@@ -611,6 +622,10 @@ func (s AuthService) SendMagicLink(ctx context.Context, req *SendMagicLinkReques
|
||||
}
|
||||
}
|
||||
|
||||
if req.MagicLinkBaseURL != nil {
|
||||
emailPresenterCfg.BaseURL = *req.MagicLinkBaseURL
|
||||
}
|
||||
|
||||
emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, fullName)
|
||||
|
||||
subject, textBody, htmlBody, err := emailPresenter.RenderMagicLink(
|
||||
|
||||
Reference in New Issue
Block a user