-
Notifications
You must be signed in to change notification settings - Fork 10
1.2. Authentication
Not all task trackers allow unauthenticated access. Even GitHub penalizes unauthenticated users by drastically dropping its API rate limit. Let's fix this by specifying your username and password for our servers.
Create the .credentials.edn
file in your home directory so you can access it with
cat ~/.credentials.edn
:
{:account
{:login "your_login_here"
:domain "YOURDOMAIN"
:password "YourSecretPassword"
:email "[email protected]"}}
This is not the only way to specify your credentials and it's definitely not the most secure, but
we will use it here as the simplest one. If necessary, feel free to change it by redefining the
flower.credentials.get-credentials
function.
So, let's get iterations from some company's internal task tracker (GitLab in the following example):
(require '[flower.credentials :as credentials])
(require '[flower.tracker.core :as tracker.core]
'[flower.tracker.proto :as tracker.proto])
(def login (credentials/get-credentials :account :login))
(def password (credentials/get-credentials :account :password))
;; Initialize the tracker component for authentication
(def tracker-component (tracker.core/start-component {:auth {:gitlab-login login
:gitlab-password password}
:context {}}))
;; Our trackers definition
(def our-trackers (tracker.core/trackers tracker-component
{:inner-gitlab {:tracker-type :gitlab
:tracker-url "https://gitlab.example.com"
:tracker-projects ["example-project"]}}))
;; Get iterations for our project using auth from tracker-component
(tracker.proto/get-iterations (first (:inner-gitlab our-trackers)))
ATTENTION! All further examples will not contain the :auth
key. However, it is implied.
It is your responsibility to ensure you have the right credentials.
You may use the following properties for :auth
:
-
:jira-login
and:jira-password
for Jira -
:tfs-login
and:tfs-password
for TFS -
:github-login
and:github-password
or:github-token
for GitHub -
:gitlab-login
and:gitlab-password
for GitLab
Here is a convenient macro that uses flower.credentials
under the hood and supplies necessary
credentials to start-component
functions. It is supposed to be used together with
flower.tracker.core/get-tracker
, flower.repository.core/get-repository
, and
flower.messaging.core/get-messaging
definitions:
(require '[flower.macros :as macros])
(require '[flower.tracker.core :as tracker.core])
(macros/with-default-credentials
(def inner-gitlab-tracker (tracker.core/get-tracker "https://gitlab.example.com/example/example-project")))