Skip to content

Commit 1f079b9

Browse files
committed
feat: add saml signout url
1 parent 4e4873c commit 1f079b9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

app/api/authentication_api.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,23 @@ class AuthenticationApi < Grape::API
153153
end
154154
redirect "#{host}/sign_in?authToken=#{onetime_token.authentication_token}&username=#{user.username}"
155155
end
156+
157+
# Saml 2 logout callback
158+
desc 'SAML2.0 logout callback'
159+
params do
160+
requires :SAMLResponse, type: String, desc: 'SAML logout response data.'
161+
end
162+
post '/auth/saml_logout' do
163+
response = OneLogin::RubySaml::Logoutresponse.new(params[:SAMLResponse], allowed_clock_drift: 1.second,
164+
settings: AuthenticationHelpers.saml_settings)
165+
166+
# Check if the SAML response is valid - if not log an error
167+
unless response.is_valid?
168+
logger.error "Invalid SAML logout response: #{response.errors.join(', ')}"
169+
end
170+
171+
redirect "#{host}/sign_in"
172+
end
156173
end
157174

158175
#
@@ -343,7 +360,7 @@ class AuthenticationApi < Grape::API
343360
end
344361

345362
# Remove the refresh token cookie - if remember is false
346-
add_refresh_cookie_to_response(false) unless params[:remember]
363+
add_refresh_cookie_to_response(false) if params[:remember]
347364
present nil
348365
end
349366

0 commit comments

Comments
 (0)