Allow API tokens to be used instead of user/pass

git-svn-id: file:///home/svn/framework3/trunk@8823 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2010-03-15 20:16:37 +00:00
parent 9f4ba25823
commit 2dd91d4f88
1 changed files with 7 additions and 6 deletions

View File

@ -9,21 +9,21 @@ class Base
end
def authenticate(token)
stale = []
@tokens.each_key do |t|
user,ctime,mtime = @tokens[t]
if(mtime + 300 < Time.now.to_i)
user,ctime,mtime,perm = @tokens[t]
if ! perm and mtime + 300 < Time.now.to_i
stale << t
end
end
stale.each { |t| @tokens.delete(t) }
if(not @tokens[token])
raise ::XMLRPC::FaultException.new(401, "authentication error")
end
@tokens[token][2] = Time.now.to_i
end
@ -31,3 +31,4 @@ class Base
end
end
end