Skip to content

Accept API Token in Authorization Header#90

Merged
winder merged 6 commits intoalgorand:masterfrom
winder:will/bearer-token
Jun 26, 2019
Merged

Accept API Token in Authorization Header#90
winder merged 6 commits intoalgorand:masterfrom
winder:will/bearer-token

Conversation

@winder
Copy link
Copy Markdown
Contributor

@winder winder commented Jun 25, 2019

Summary

We have a metrics endpoint to provide prometheus style metrics, it also requires the X-Algo-API-Token: <token> header. Some tools which are able to consume this endpoint, like Telegraf, assume authorization tokens will be provided as bearer tokens, like Authorization: Bearer <token>. So this adds that as a fallback.

Test Plan

Make sure both forms still work:

will@will-algorand:~$ curl http://localhost:10101/v1/status -H "Authorization: Bearer $(cat ~/.algorand/algod.token)"
{"lastRound":253920,"lastConsensusVersion":"https://github.com/algorandfoundation/specs/tree/5615adc36bad610c7f165fa2967f4ecfa75125f0","nextConsensusVersion":"https://github.com/algorandfoundation/specs/tree/5615adc36bad610c7f165fa2967f4ecfa75125f0","nextConsensusVersionRound":253921,"nextConsensusVersionSupported":true,"timeSinceLastRound":2006682505,"catchupTime":0}
will@will-algorand:~$ curl http://localhost:10101/v1/status -H "X-Algo-API-Token: $(cat ~/.algorand/algod.token)"
{"lastRound":253922,"lastConsensusVersion":"https://github.com/algorandfoundation/specs/tree/5615adc36bad610c7f165fa2967f4ecfa75125f0","nextConsensusVersion":"https://github.com/algorandfoundation/specs/tree/5615adc36bad610c7f165fa2967f4ecfa75125f0","nextConsensusVersionRound":253923,"nextConsensusVersionSupported":true,"timeSinceLastRound":3927344369,"catchupTime":0}

@winder winder requested a review from rotemh June 25, 2019 16:53
Comment thread daemon/algod/api/server/lib/middlewares/auth.go Outdated
Comment thread daemon/algod/api/server/lib/middlewares/auth.go Outdated
@winder winder requested a review from rotemh June 26, 2019 13:25
@winder winder merged commit d722a8c into algorand:master Jun 26, 2019
@winder winder deleted the will/bearer-token branch March 10, 2020 14:48
algorandskiy pushed a commit to algorandskiy/go-algorand that referenced this pull request May 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants