Skip to content

Commit 9260c9e

Browse files
authored
Remove all fields from SSO cookie except name and uuid (#1667)
1 parent 1178fd8 commit 9260c9e

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Api::V1
2+
class SsoCookieRepresenter < Roar::Decorator
3+
include Roar::JSON
4+
5+
property :name,
6+
type: String,
7+
readable: true,
8+
writeable: false
9+
10+
property :uuid,
11+
type: String,
12+
readable: true,
13+
writeable: false
14+
end
15+
end

lib/sso_cookie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module SsoCookie
1414
@encryption_method = secrets[:encryption_method]
1515

1616
def self.user_hash(user)
17-
Api::V1::UserRepresenter.new(user).to_hash
17+
Api::V1::SsoCookieRepresenter.new(user).to_hash
1818
end
1919

2020
# This method is used in 2 different ways:

spec/controllers/api/v1/users_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@
408408

409409
sso_cookie = parsed_response['sso']
410410
sso_hash = SsoCookie.read sso_cookie
411-
expect(sso_hash['sub']).to eq Api::V1::UserRepresenter.new(new_user).to_hash
411+
expect(sso_hash['sub']).to eq Api::V1::SsoCookieRepresenter.new(new_user).to_hash
412412
expect(sso_hash['exp']).to be <= (
413413
Time.current + Api::V1::UsersController::SSO_TOKEN_INITIAL_DURATION
414414
).to_i

0 commit comments

Comments
 (0)