Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3272942
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:52:46+00:00 2026-05-17T18:52:46+00:00

I’m implementing DotNetOpenAuth (OpenID) and Forms Authentication as the authentication mechanism for a site

  • 0

I’m implementing DotNetOpenAuth (OpenID) and Forms Authentication as the authentication mechanism for a site I’m building. However, I’m not happy with parts of the solution I’ve come up with and though I should check with you guys how it is usually done.

I have set the Forms Authentication loginUrl to login.aspx. This is the code behind for the login page:


public partial class Login : DataAccessPage {
    protected void Page_Load(object sender, EventArgs e) {
        if (Request.QueryString["dnoa.receiver"] != "openId") {
            openId.ReturnToUrl = Request.Url.ToString();
            openId.LogOn();
        }
    }

    protected void openId_LoggedIn(object sender, DotNetOpenAuth.OpenId.RelyingParty.OpenIdEventArgs e) {
        var fetch = e.Response.GetExtension();

        if (fetch != null) {
            string eMail = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);
            string name = fetch.GetAttributeValue(WellKnownAttributes.Name.FullName);

            var usr = db.Users.SingleOrDefault(u => u.EMailAddress == eMail);

            if (usr != null) {
                // update the name in db if it has been changed on Google
                if (usr.Name != name) {
                    usr.Name = name;
                    db.SaveChanges();
                }

                FormsAuthentication.RedirectFromLoginPage(usr.UserId.ToString(), false);
            }
        }
    }

    protected void openId_LoggingIn(object sender, DotNetOpenAuth.OpenId.RelyingParty.OpenIdEventArgs e) {
        var fetch = new FetchRequest();
        fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
        fetch.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
        e.Request.AddExtension(fetch);
    }
}

So directly when a user is not logged in, it is sent to the login.aspx-page which directly tries to log it in using OpenID against Google. It checks if the user is on the list of allowed users, and then FormsAuthentication.RedirectFromLoginPage().

So far no problem… the problem is at sign out. Ideally I would like the sign in to be directly connected to the Google Account sign in status. If the user is signed in to Google, he/she should also be signed in at my site. When the user logs out of Google, he/she should be logged out from my site. However, since Forms Authentication is used, the ticket will last some time even if the user signs out of Google.

Anyone have any ideas on how to solve this?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:52:47+00:00Added an answer on May 17, 2026 at 6:52 pm

    First to answer your question: OpenID does not provide a means to tie the length of the Google session to your own session. The best you can do is provide a session-only (non-persistent) cookie as it looks you’re already doing, so that if the user logs out of Google and closes their browser they’ll be logged out of your site as well. This is an OpenID protocol limitation — no other OpenID library can fix it either.

    Now to the issue you didn’t ask for, but I can’t ignore it — you’re implementation is quite unsafe. You are trusting the AX fetch response extension implicitly, allowing whatever email address it claims the user controls be the user who is logged in. This means anyone can trivially set up an OpenID Provider that lies about the email address and spoof your users’ identity. You may be incorrectly assuming that just because you redirect your users to Google that that means all responses come from Google (and assuming you trust Google). Just because you send a request to Google, doesn’t mean someone can’t synthesize a response from their own non-Google server.

    There are two ways to solve your security problem. First (and preferably) don’t use email address as your username. Use the IAuthenticationResponse.ClaimedIdentifier as the username instead. That’s what it’s there for, and will protect you against many different attacks. The less preferable fix is to keep using email, but to verify that the response is in fact coming from Google before you trust that email. You can do this via the IAuthenticationResponse.Provider.Uri property and verify that it is the one(s) you are expecting and trust.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.