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

Allow auth by API key, don't pass password to methods not using it #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions rally-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

(defvar rally-user)
(defvar rally-password)
(defvar rally-api-key)
(defvar rally-tasks-cache nil)

(define-derived-mode rally-mode special-mode "rally-mode"
Expand Down Expand Up @@ -78,38 +79,43 @@
(concat url-server-string "?"
(url-build-query-string params)))

(defun rally--auth-header (user pass)
(if (boundp 'rally-api-key)
(cons "zsessionid" rally-api-key)
(cons "Authorization" (concat "Basic "
(base64-encode-string
(concat user ":" pass))))))

(defun rally-basic-auth (url user pass)
;;(princ url)
(let ((xyz-block-authorisation t)
(url-request-method "GET")
(url-queue-timeout 60)
(url-request-extra-headers
`(("Content-Type" . "application/xml")
("Authorization" . ,(concat "Basic "
(base64-encode-string
(concat user ":" pass)))))))
,(rally--auth-header user pass))))
(with-current-buffer (url-retrieve-synchronously url t)
(delete-region 1 url-http-end-of-headers)
(buffer-string)
)))

(defun rally-make-url-lst (username password)
(defun rally-make-url-lst (username)
`(
(query ,(format "((Owner.Name = %s ) AND (( Iteration.StartDate <= today ) AND (Iteration.EndDate >= today)) )" username ) )
(order Rank)
(fetch "true,WorkProduct,Tasks,Iteration,Estimate,State,ToDo,Name,Description,Type")
))

(defun rally-make-query (username password)
(defun rally-make-query (username)
(rally-build-url
"https://rally1.rallydev.com/slm/webservice/v2.0/task"
(rally-make-url-lst username password)
(rally-make-url-lst username)
))

(defun rally-current-iteration-info (username password)
(rally-basic-auth
(rally-make-query username password)
username
(rally-make-query username)
username
password))

(defun rally-extract-info (lst)
Expand Down