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
6 changes: 5 additions & 1 deletion lib/workos/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class Profile
include HashProvider

attr_accessor :id, :email, :first_name, :last_name, :role, :groups, :organization_id,
:connection_id, :connection_type, :idp_id, :raw_attributes
:connection_id, :connection_type, :idp_id, :custom_attributes, :raw_attributes

# rubocop:disable Metrics/AbcSize
def initialize(profile_json)
hash = JSON.parse(profile_json, symbolize_names: true)

Expand All @@ -25,8 +26,10 @@ def initialize(profile_json)
@connection_id = hash[:connection_id]
@connection_type = hash[:connection_type]
@idp_id = hash[:idp_id]
@custom_attributes = hash[:custom_attributes]
@raw_attributes = hash[:raw_attributes]
end
# rubocop:enable Metrics/AbcSize

def full_name
[first_name, last_name].compact.join(' ')
Expand All @@ -44,6 +47,7 @@ def to_json(*)
connection_id: connection_id,
connection_type: connection_type,
idp_id: idp_id,
custom_attributes: custom_attributes,
raw_attributes: raw_attributes,
}
end
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/workos/sso_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
},
groups: nil,
organization_id: 'org_01FG53X8636WSNW2WEKB2C31ZB',
custom_attributes: {},
raw_attributes: {
email: '[email protected]',
family_name: 'Loblaw',
Expand Down Expand Up @@ -381,13 +382,17 @@
},
groups: %w[Admins Developers],
organization_id: 'org_01FG53X8636WSNW2WEKB2C31ZB',
custom_attributes: {
license: 'professional',
},
raw_attributes: {
email: '[email protected]',
first_name: 'WorkOS',
id: 'prof_01DRA1XNSJDZ19A31F183ECQW5',
idp_id: '00u1klkowm8EGah2H357',
last_name: 'Demo',
groups: %w[Admins Developers],
license: 'professional',
},
}

Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures/vcr_cassettes/sso/profile.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/support/profile.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"profile":{"object":"profile","id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"[email protected]","first_name":"WorkOS","organization_id":"org_01FG53X8636WSNW2WEKB2C31ZB","connection_id":"conn_01EMH8WAK20T42N2NBMNBCYHAG","connection_type":"OktaSAML","last_name":"Demo","role":{"slug": "admin"},"groups":["Admins","Developers"],"idp_id":"00u1klkowm8EGah2H357","raw_attributes":{"id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"[email protected]","first_name":"WorkOS","last_name":"Demo","groups":["Admins","Developers"],"idp_id":"00u1klkowm8EGah2H357"}},"access_token":"01DVX6QBS3EG6FHY2ESAA5Q65X"}
{"profile":{"object":"profile","id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"[email protected]","first_name":"WorkOS","organization_id":"org_01FG53X8636WSNW2WEKB2C31ZB","connection_id":"conn_01EMH8WAK20T42N2NBMNBCYHAG","connection_type":"OktaSAML","last_name":"Demo","role":{"slug": "admin"},"groups":["Admins","Developers"],"idp_id":"00u1klkowm8EGah2H357","custom_attributes":{"license": "professional"},"raw_attributes":{"id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"[email protected]","first_name":"WorkOS","last_name":"Demo","groups":["Admins","Developers"],"idp_id":"00u1klkowm8EGah2H357","license": "professional"}},"access_token":"01DVX6QBS3EG6FHY2ESAA5Q65X"}
Loading