Skip to content

Commit bf31bff

Browse files
author
Peter Karman
committed
add doc example for encryption and logout
1 parent a176273 commit bf31bff

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,36 @@ Add to your `routes.rb` file, for example:
3636
get '/saml/auth' => 'saml_idp#new'
3737
get '/saml/metadata' => 'saml_idp#show'
3838
post '/saml/auth' => 'saml_idp#create'
39+
match '/saml/logout' => 'saml_idp#logout', via: [:get, :post, :delete]
3940
```
4041

4142
Create a controller that looks like this, customize to your own situation:
4243

4344
``` ruby
44-
class SamlIdpController < SamlIdp::IdpController
45+
class SamlIdpController
46+
include SamlIdp::IdpController
47+
4548
def idp_authenticate(email, password) # not using params intentionally
4649
user = User.by_email(email).first
4750
user && user.valid_password?(password) ? user : nil
4851
end
4952
private :idp_authenticate
5053

5154
def idp_make_saml_response(found_user) # not using params intentionally
52-
encode_response found_user
55+
# NOTE encryption is optional
56+
encode_response found_user, encryption: {
57+
cert: saml_request.service_provider.cert,
58+
block_encryption: 'aes256-cbc',
59+
key_transport: 'rsa-oaep-mgf1p'
60+
}
5361
end
5462
private :idp_make_saml_response
63+
64+
def idp_logout
65+
user = User.by_email(saml_request.name_id)
66+
user.logout
67+
end
68+
private :idp_logout
5569
end
5670
```
5771

app/controllers/saml_idp/idp_controller.rb

+11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def create
2929
render :template => "saml_idp/idp/new"
3030
end
3131

32+
def logout
33+
idp_logout
34+
@saml_response = idp_make_saml_response(nil)
35+
render :template => "saml_idp/idp/saml_post", :layout => false
36+
end
37+
38+
def idp_logout
39+
raise NotImplementedError
40+
end
41+
private :idp_logout
42+
3243
def idp_authenticate(email, password)
3344
raise NotImplementedError
3445
end

0 commit comments

Comments
 (0)