Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSSE UsernameToken rejected by server without modifications #157

Closed
timconnolly opened this issue Feb 14, 2011 · 2 comments
Closed

WSSE UsernameToken rejected by server without modifications #157

timconnolly opened this issue Feb 14, 2011 · 2 comments

Comments

@timconnolly
Copy link

There seems to be a problem with the way that wsse:Nonce, wsu:Created, and the password digest are built. I was unable to authenticate without making changes to the v0.8.5 code.

In regards to the timestamp:
http://www.oasis-open.org/committees/download.php/21256/wss-v1.1-spec-errata-os-SOAPMessageSecurity.htm#_Toc118717167 states that "All times MUST be in UTC format".

I am currently using the following monkey patch to build the nonce and digest:

class Savon::WSSE
  def wsse_username_token
    if digest?
      wsse_security "UsernameToken",
        "wsse:Username" => username,
        "wsse:Nonce" => Base64.encode64(nonce).chomp!,
        "wsu:Created" => timestamp,
        "wsse:Password" => digest_password,
        :attributes! => { "wsse:Password" => { "Type" => PasswordDigestURI } }
    else
      wsse_security "UsernameToken",
        "wsse:Username" => username,
        "wsse:Password" => password,
        :attributes! => { "wsse:Password" => { "Type" => PasswordTextURI } }
    end
  end

  def digest_password
    token = nonce + timestamp + password
    Base64.encode64(Digest::SHA1.digest(token)).chomp!
  end

  def nonce
    @nonce ||= Digest::SHA1.digest random_string + timestamp
  end

  def timestamp
      @timestamp ||= Time.now.utc.xs_datetime
  end
end

module Savon::CoreExt::Time
  def xs_datetime
      strftime "%Y-%m-%dT%H:%M:%SZ"
  end
end
@rubiii
Copy link
Contributor

rubiii commented May 7, 2011

to summarize, you changed the following three lines of code:

# Savon::WSSE#wsse_username_token (line 4)
"wsse:Nonce" => Base64.encode64(nonce).chomp!

# Savon::WSSE#timestamp (line 1)
@timestamp ||= Time.now.utc.xs_datetime

# Savon::CoreExt::Time#xs_datetime
strftime "%Y-%m-%dT%H:%M:%SZ"

do you still have to monkey patch this in a more recent version of savon?
and can you (or anybody else) elaborate on why this needs to be changed?

@rubiii
Copy link
Contributor

rubiii commented Nov 5, 2011

closing this issue as it's better represented by rubiii/akami#1

@rubiii rubiii closed this as completed Nov 5, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants