sirp icon indicating copy to clipboard operation
sirp copied to clipboard

Design changes RFC

Open Ptico opened this issue 8 years ago • 6 comments

Hi, since library going to 2.0, and it doesn't compatible with 1.x anyway, i want to propose some possible simplifications in API.

What about this kind of interface?

#### Configuration
SIRP.configure do |sirp|
  sirp.prime_length = 2048
  sirp.hash = Digest::SHA256
end

#### Session start
user = DB[:users].where(login: login).first
# or
user = { login: 'ptico', verifier: 'xxx', salt: 'xxx' }

if user
  start = SIRP::Server::Start.new(user, params['A'])
  start.proof # Store proof in session
  start.challenge # Send challenge to client
else
  # throw 401
end

#### Session finish

finish = SIRP::Server::Finish.new(proof, params['M'])
if finish.success?
  finish.match # Send H(A,M,K) to client
else
  # throw 401
end

Ptico avatar Jul 01 '16 16:07 Ptico

This is not a big changes, but allows to split responsibility and simplify both development and usage

Ptico avatar Jul 01 '16 16:07 Ptico

Thanks for the proposal. I'd like to take a little while to think this over and consider the changes I would need in the API of a matching TypeScript client I started.

I am currently traveling so it might be a couple of weeks until I can devote some time to thinking that through.

I appreciate the help.

grempe avatar Jul 03 '16 02:07 grempe

I'll be happy to implement this or other changes after your approval, so let's discuss when you'll be back. Enjoy your trip. Thanks!

Ptico avatar Jul 04 '16 11:07 Ptico

Any news?

Ptico avatar Sep 02 '16 00:09 Ptico

Sorry, I lost track of this. I think your idea looks good and is an improvement on what I had (which was probably dictated more by the spec and the previous implementation than great API design choices).

If you are still game to implement this I'd be happy to review it with you and get it merged.

I have not had much time to work on the Typescript implementation I was working on either. It was really only skeletal. If you have any interest in that I'd love the help (I could use it!).

Cheers.

grempe avatar Sep 03 '16 02:09 grempe

Cool, i will try to make a PR on the weekend.

Regarding Typescript implementation: I don't have an experience with it, but let's discuss how I can help in IRC or something like this

Ptico avatar Sep 07 '16 16:09 Ptico