Saturday, February 23, 2008 

Silverlight Animated Optical Illusion

Spotted this illusion on digg: The anatomy of an illusion -- and what it tells us about the visual system. Being the skepical fellow I am - I decided to recreate this illusion.

The animation is simply cycling the colours of inner circles. From/to the frames below.

So, here's my Silverlight version of the animated illusion. Feeling skeptical yourself? View the source!

Labels:

Monday, February 18, 2008 

ObjectDataSource DateTime, and Locale

Thinking of using an ObjectDataSource and DetailsView to populate/save your business object? If the object has a DateTime property - lets hope you live in the United States!

Had an strange problem today with a birthday set to October 9, 1940. The edit screen would populate a TextBox with "9/10/1940", correct for my culture en-AU. Clicking save populates the database with "September 10, 1940". Strange the edit screen would observe the my culture settings, yet populating the business object doesn't.

Googling around turned up this: ObjectDataSource ignores culture information when updating. Do'h!

Labels:

Tuesday, February 12, 2008 

How Does OpenID Work?

I've heard about OpenID on a podcast I listen to. Sounds interesting - an open source solution to have a 'single sign on' for many websites. Interested to see how this works - both as a user, and as a website author.

Here's a run through of an example authentication:

  1. User accesses an OpenID enabled website, site responds with a form requesting the user's OpenID identity.
  2. User enters their identity, e.g: russau.myopenid.com. Then submits the form to the website.
  3. Website server accesses http://russau.myopenid.com.
  4. Retrieves the location of the OpenID provider from the link tag:
    <link rel="openid.server" href="http://www.myopenid.com/server" />
  5. Website POSTs an 'associate' request to the provider. The two machines establish a secret using a Diffie-Hellman key exchange.
    openid.modeassociate
    openid.assoc_typeHMAC-SHA1
    openid.session_typeDH-SHA1
    openid.dh_consumer_public
    openid.dh_modulus
    openid.dh_genAg==
  6. Provider's response provides the website an 'assoc_handle' (and expiry) for future requests. The two servers now have established a shared secret, without passing it over the wire.
  7. assoc_handle{HMAC-SHA1}{47b0ec92}{5hMN8A==}
    assoc_typeHMAC-SHA1
    dh_server_public
    enc_mac_key
    expires_in1209600
    session_typeDH-SHA1
  8. The comsumer's response from step 2 contains a redirect to the provider, containing a number of parameters in the querystring. Note, the querystring contains the established 'assoc_handle', and a 'nonce' has been attached onto the 'return_to'.
    openid.modecheckid_setup
    openid.identityhttp://russau.myopenid.com/
    openid.return_tohttp://openidconsumer.test/cp/login.aspx?&nonce=vovudmLa
    openid.trust_roothttp://openidconsumer.test/cp
    openid.assoc_handle{HMAC-SHA1}{47b0ec92}{5hMN8A==}
    openid.sreg.requiredgender,postcode,timezone
    openid.sreg.optionalemail,country
    openid.sreg.policy_url
  9. The user is now on the provider website, and performs the step needed to authenticate, e.g. entering a password.
  10. The provider redirects the user back to the consumer website, along with parameters in the querystring. The consumer now has everything it needs to log in the user.
    noncevovudmLa
    openid.assoc_handle{HMAC-SHA1}{47b0ec92}{5hMN8A==}
    openid.identityhttp://russau.myopenid.com/
    openid.modeid_res
    openid.op_endpointhttp://www.myopenid.com/server
    openid.response_nonce2008-02-12T00:47:53ZyUUam3
    openid.return_tohttp://openidconsumer.test/cp/login.aspx?nonce=vovudmLa
    openid.sigEpvWdJtxacv2WtCaZLbud85M84k=
    openid.signedassoc_handle, identity, mode, op_endpoint, response_nonce, return_to, signed, sreg.country, sreg.email
    openid.sreg.countryAU
    openid.sreg.emailtestuser@webmail.com
    This querystring contains a couple of things to prevent an attacker from spoofing it. The 'assoc_handle' established in steps 5 and 6, the consumer uses to this look up the established secret. 'openid.sig' contains a digital signature of the parameter values listed in 'openid.signed', using the established secret. If an attacker were to change the 'openid.identity' in an attempt to login as someone else, the signature wouldn't match (without knowing the secret, the attacker cannot re-create the signature). Finally, the initial 'openid.return_to' in step 7 contained a nonce. If an attacker were to resubmit the querystring above unchanged (a replay attack), the consumer web site would know the nonce has already been used.

Further reading

Labels: ,