Fix role and organization logo

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-10-30 22:42:17 +01:00
parent aabad5087c
commit d1c31978da
14 changed files with 177 additions and 74 deletions

View File

@@ -19,6 +19,7 @@ import (
"strings"
"github.com/crewjam/saml"
"github.com/getprobo/probo/pkg/coredata"
)
func ExtractAttributeValue(assertion *saml.Assertion, attributeName string) (string, error) {
@@ -76,12 +77,12 @@ func ExtractEmailDomain(email string) (string, error) {
return domain, nil
}
func MapSAMLRoleToSystemRole(samlRole string) string {
func MapSAMLRoleToSystemRole(samlRole string) coredata.Role {
if samlRole != "" && isValidRole(samlRole) {
return samlRole
return coredata.Role(samlRole)
}
return "MEMBER"
return coredata.RoleMember
}
func isValidRole(role string) bool {

View File

@@ -407,7 +407,7 @@ func (s *SAMLService) InitiateSAMLLogin(
type SAMLUserInfo struct {
Email string
FullName string
Role string
Role coredata.Role
SAMLSubject string
OrganizationID gid.GID
SAMLConfigID gid.GID

View File

@@ -1055,15 +1055,9 @@ func (s Service) GetOrganizationLogoFile(
organizationID gid.GID,
session *coredata.Session,
) (*coredata.File, error) {
// Check authentication requirements before allowing access to logo
err := s.CheckSingleOrganizationAccess(ctx, user, organizationID, session)
if err != nil {
return nil, fmt.Errorf("access denied: %w", err)
}
var logoFile *coredata.File
err = s.pg.WithConn(
err := s.pg.WithConn(
ctx,
func(conn pg.Conn) error {
scope := coredata.NewScope(organizationID.TenantID())