Skip to content
Merged
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: 6 additions & 2 deletions pkg/sso/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/google/go-querystring/query"
"github.com/workos/workos-go/v4/pkg/workos_errors"
"net/http"
"net/url"
"strings"
"sync"
"time"

"github.com/google/go-querystring/query"
"github.com/workos/workos-go/v4/pkg/workos_errors"

"github.com/workos/workos-go/v4/internal/workos"
"github.com/workos/workos-go/v4/pkg/common"
)
Expand Down Expand Up @@ -255,6 +256,9 @@ type Profile struct {
// The user's group memberships. Can be empty.
Groups []string `json:"groups"`

// The mapped custom attributes from the identity provider. Can be empty.
CustomAttributes map[string]interface{} `json:"custom_attributes"`

// The raw response of Profile attributes from the identity provider
RawAttributes map[string]interface{} `json:"raw_attributes"`
}
Expand Down
24 changes: 20 additions & 4 deletions pkg/sso/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,16 @@ func TestClientGetProfileAndToken(t *testing.T) {
Role: common.RoleResponse{
Slug: "admin",
},
Groups: []string{"Admins", "Developers"},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
},
RawAttributes: map[string]interface{}{
"idp_id": "123",
"email": "foo@test.com",
"first_name": "foo",
"last_name": "bar",
"license": "professional",
},
},
},
Expand Down Expand Up @@ -223,12 +227,16 @@ func profileAndTokenTestHandler(w http.ResponseWriter, r *http.Request) {
Role: common.RoleResponse{
Slug: "admin",
},
Groups: []string{"Admins", "Developers"},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
},
RawAttributes: map[string]interface{}{
"idp_id": "123",
"email": "foo@test.com",
"first_name": "foo",
"last_name": "bar",
"license": "professional",
},
},
})
Expand Down Expand Up @@ -270,12 +278,16 @@ func TestClientGetProfile(t *testing.T) {
Role: common.RoleResponse{
Slug: "admin",
},
Groups: []string{"Admins", "Developers"},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
},
RawAttributes: map[string]interface{}{
"idp_id": "123",
"email": "foo@test.com",
"first_name": "foo",
"last_name": "bar",
"license": "professional",
},
},
},
Expand Down Expand Up @@ -325,12 +337,16 @@ func profileTestHandler(w http.ResponseWriter, r *http.Request) {
Role: common.RoleResponse{
Slug: "admin",
},
Groups: []string{"Admins", "Developers"},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
},
RawAttributes: map[string]interface{}{
"idp_id": "123",
"email": "foo@test.com",
"first_name": "foo",
"last_name": "bar",
"license": "professional",
},
},
)
Expand Down
12 changes: 10 additions & 2 deletions pkg/sso/sso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ func TestLogin(t *testing.T) {
Role: common.RoleResponse{
Slug: "admin",
},
Groups: []string{"Admins", "Developers"},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
},
RawAttributes: map[string]interface{}{
"idp_id": "123",
"email": "foo@test.com",
"first_name": "foo",
"last_name": "bar",
"license": "professional",
},
}

Expand Down Expand Up @@ -172,12 +176,16 @@ func TestSsoGetProfile(t *testing.T) {
Role: common.RoleResponse{
Slug: "admin",
},
Groups: []string{"Admins", "Developers"},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
},
RawAttributes: map[string]interface{}{
"idp_id": "123",
"email": "foo@test.com",
"first_name": "foo",
"last_name": "bar",
"license": "professional",
},
}
profileResponse, err := GetProfile(context.Background(), GetProfileOpts{
Expand Down
Loading