Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Add SLO and SSO endpoints for Login.gov #1476

Merged
merged 8 commits into from
Jan 9, 2017
Merged

Add SLO and SSO endpoints for Login.gov #1476

merged 8 commits into from
Jan 9, 2017

Conversation

jessieay
Copy link
Contributor

@jessieay jessieay commented Dec 22, 2016

* Use `SessionsController`
* This means users can sign in and out with Login.gov
* This is based off of code in https://github.com/18F/identity-sp-rails
* Next steps:
  - protect this route so that only logged-in admins can see it
  - add whitelisting for certain users who log in with login.gov to be
    admins
  - add this config to identity-idp repo
if params.key?(:loa)
request.env['omniauth.strategy'].options[:authn_context] = [
"http://idmanagement.gov/ns/assurance/loa/#{params[:loa]}",
'http://idmanagement.gov/ns/requested_attributes?ReqAttr=email,phone,first_name,last_name,ssn'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need SSN for this app? Don't ask for it unless you have a business need, because that's PII.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! didn't even see this. We do not need it. Removing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed at 46cf31f

@mtorres253
Copy link
Contributor

mtorres253 commented Dec 22, 2016 via email

jessieay added a commit to 18F/identity-idp that referenced this pull request Dec 23, 2016
**Why**: This is a required step for adding a new service provider
* See 18F/micropurchase#1476
def setup
if params.key?(:loa)
request.env['omniauth.strategy'].options[:authn_context] = [
"http://idmanagement.gov/ns/assurance/loa/#{params[:loa]}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm new to all of this identity stuff. What are these URLs? Is it OK that they are HTTP and not HTTPS?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, http is fine here. These are identifiers, not actual addressable URLs.

render inline: error_msg
end

def validate_slo_response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does slo stand for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single Logout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was also very confusing to me at first! while I am generally allergic to acronyms, this one seems pretty broadly accepted in the "single log out" world. do you think we should use full name, @adelevie ?


delegate :email, :uid, to: :user

attr_reader :asserted_attributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does asserted_attributes mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the x509 cert -- we use a fingerprint of this cert so that the "service provider" (in this case, the identity idp app) knows who is making the request.

the way one SO responder but it:

You can use the public key to verify that the content of the SAML response matches the key - in other words - that response definitely came from someone who has the matching private key to the public key in the message, and the response hasn't been tampered with.

this is the public key. :)

more info here: https://developers.onelogin.com/saml/ruby

also, I may be messing this all up. but this is my working understanding. still learning myself!

Copy link

@pkarman pkarman Jan 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not to be too pedantic, but the service provider is micropurchase. The identity idp app is the identity provider.

the cert belongs to the SP (micropurchase) and is registered with the IdP. Likewise, the Idp may register its public cert with the SP. The certs are used as @jessieay indicates: to verify the incoming requests are signed from the org they claim to be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. Sorry to mix up the words and create even more confusion in an already confusing world!

validates :sam_status, presence: true

enum sam_status: { duns_blank: 0, sam_accepted: 1, sam_rejected: 2, sam_pending: 3 }

def self.from_omniauth(auth)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that once we actually let users sign in with login.gov, this will find an existing user via email rather than find or create. doing it this way for now so it's easier to test, but we can also make it just FIND if people are uncomfortable with this bandaid

validates :github_id, presence: true
validates :github_login, presence: true
validates :github_id, presence: true, if: :not_login_user?
validates :github_login, presence: true, if: :not_login_user?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these if validations will be removed in the future.

Copy link
Contributor

@nickbristow nickbristow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes more sense semantically, compared to sessions_controller

@jessieay jessieay merged commit bacc012 into develop Jan 9, 2017
@jessieay jessieay deleted the jy-saml-oauth-2 branch January 9, 2017 21:53
jessieay added a commit to 18F/identity-idp that referenced this pull request Jan 11, 2017
**Why**: This is a required step for adding a new service provider
* See 18F/micropurchase#1476
amoose pushed a commit to 18F/identity-idp that referenced this pull request Feb 7, 2017
**Why**: This is a required step for adding a new service provider
* See 18F/micropurchase#1476
amoose pushed a commit to 18F/identity-idp that referenced this pull request Feb 24, 2017
**Why**: This is a required step for adding a new service provider
* See 18F/micropurchase#1476
amoose pushed a commit to 18F/identity-idp that referenced this pull request Feb 28, 2017
**Why**: This is a required step for adding a new service provider
* See 18F/micropurchase#1476
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants