sirp
sirp copied to clipboard
Design changes RFC
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
This is not a big changes, but allows to split responsibility and simplify both development and usage
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.
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!
Any news?
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.
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