Skip to content
Open
Show file tree
Hide file tree
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
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## Setup

### Environment
The following credentials type are supported: Basic Auth (password of the admin
account) or Bearer Auth.

### Password with Environment variable

Specify the admin password by running the following two commands

Expand All @@ -19,7 +22,7 @@ export API_HOST=https://hawkbit.example.com

Remember that you will have to reenter your password whenever you switch `API_HOST`

### netrc
### Password with .netrc

You can also configure your credentials with the help of `~/.netrc` (see
`curl(1) --netrc` for more information)
Expand All @@ -32,6 +35,23 @@ Also remember to set the permissions correctly:

chmod 600 ~/.netrc

### Bearer Authentication

Get an access_token from an OAUTH2 server plugged to the Hawkbit one.

```
export BEARER_TOKEN
BEARER_TOKEN=$(curl \
-d "client_id=$OAUTH_CLIENT_ID" \
-d "client_secret=$OAUTH_CLIENT_SECRET" \
-d "grant_type=client_credentials" \
$OAUTH_URL \
| jq --exit-status --raw-output .access_token)
```

Remember that access tokens could have a short lifetime (several minutes).
Check `expires_in` field of the response.

## Usage

```
Expand Down
2 changes: 2 additions & 0 deletions src/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ fi
if [ -n "$PASSWORD" ]; then
# shellcheck disable=SC2034
CURL_AUTH_ARGS=(--user "admin:$PASSWORD")
elif [ -n "$BEARER_TOKEN" ]; then
CURL_AUTH_ARGS=(-H "Authorization: Bearer $BEARER_TOKEN")
elif [ -f ~/.netrc ] && grep --quiet "${API_HOST##*://}" ~/.netrc; then
# shellcheck disable=SC2034
CURL_AUTH_ARGS=(--netrc)
Expand Down