-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Authentication for HTTP/HTTPS datasources #113
Comments
@abnerjacobsen Hi, thanks for logging this - always good to meet new gomplate users! I've started thinking about how to implement this months ago, and truth be told it fell by the wayside. What would be the best interface for your use-case? Would something like an |
Ideally, you can enter the required header as a command-line option. In case of my API has to be the following:
Other examples I found on the internet: Http://jwt.io: Https://api.data.gov/docs/api-key: Http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-api-keys.html Https://api.cloudflare.com/#getting-started-requests
In the case of Cloudflare 2 HTTP headers are required to authenticate. For this reason it is ideal to be able to set one or more HTTP headers, as is done with the curl using the --header option. |
Ok, thanks @abnerjacobsen, that helps. Since the headers should only be sent with one datasource (wouldn't want secret tokens being sent to the wrong URLs!), I'm thinking a command like this might work: $ gomplate --datasource daspanel=http://api.daspanel.site/1.0/sites/httpconf/mydomain.com --datasource-header 'daspanel=Authorization: myauthtoken' --datasource-header 'daspanel=Accept: application/json' < foo.template As a short-form to As an aside, Does this all sound 👍 to you? I'll try to find some time to get started implementing this soon. |
@hairyhenderson This proposed implementation is fine for me. Thank you for your attention to this request. |
@abnerjacobsen I've implemented this in #115 - it'll be released as part of v1.6.0 |
I'm using gomplate to generate the configurations of docker containers in a project I keep named Daspanel. So far I've used the datasource coming from a file with success, but now I need to get data from an API using authentication through a token that has to be passed using an HTTP header. An example of calling the API using curl is below:
curl -X GET --header 'Accept: application/json' --header 'Authorization: myauthtoken' 'http://api.daspanel.site/1.0/sites/httpconf/mydomain.com'
I looked in the documentation but found no example of how to pass a header when using the HTTP/HTTPS datasource. Is this possible ? If not, could you consider adding this feature to gomplate?
With this feature gomplate can directly consume json data from APIs that use token or JWT authentication.
The text was updated successfully, but these errors were encountered: