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

📝 Session Token Authenticator documentation #28762

Merged
merged 5 commits into from
Jul 31, 2023

Conversation

lmossman
Copy link
Contributor

What

Relates to #26901

How

Updates the Connector Builder authentication documentation to explain when and how to use the Session Token authenticator.

@lmossman lmossman requested a review from flash1293 July 27, 2023 00:24
@octavia-squidington-iii octavia-squidington-iii added the area/documentation Improvements or additions to documentation label Jul 27, 2023
@@ -143,6 +144,47 @@ In a lot of cases, OAuth refresh tokens are long-lived and can be used to create

This can be done using the "Overwrite config with refresh token response" setting. If enabled, the authenticator expects a new refresh token to be returned from the token refresh endpoint. By default, the property `refresh_token` is used to extract the new refresh token, but this can be configured using the "Refresh token property name" setting. The connector then updates its own configuration with the new refresh token and uses it the next time an access token needs to be generated. If this option is used, it's necessary to specify an initial access token along with its expiry date in the "Testing values" menu.

### Session Token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also update docs/connector-development/connector-builder-ui/connector-builder-compatibility.md to mention this as a supported type (there's another error on that page about single-use refresh token which are supported now, could you fix that as well)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout, added

- `Request Headers` - used to attach headers to the sesssion token retrieval request
- Metabase does not require any headers in the `/api/session` request, so this is left unset.
- `Request Body` - used to attach a request body to the session token retrieval request
- As mentioned above, Metabase requires the username and password to be sent in the request body, so we can select `JSON (key-value pairs)` here and set the username and password fields (using User Inputs for the values to make the connector reusable).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you spell out the keys and values here that need to be set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- For Metabase, the `/api/session` response looks like `{"id":"<session-token-value>"}`, so the value here would simply be `id`.
- `Expiration Duration` - an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) indicating how long the session token has until it expires
- Once this duration is reached, your connector will automatically fetch a new session token, and continue making data requests with that new one.
- If this is left unset, the session token will be refreshed before every single data request.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a note here that in most cases it makes sense to set the expiration date as the connector will run much slower than necessary otherwise?

- Choose `API Key` if your session token needs to be injected into a query parameter or header of the data requests.
- Metabase takes in the session token through a specific header, so this would be set to `API Key`, Inject Session Token into outgoing HTTP Request would be set to `Header`, and Header Name would be set to `X-Metabase-Session`.
- Choose `Bearer` if your session token needs to be sent as a standard Bearer token.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a note that the session token authenticator does not support dynamic expiration dates of the session token and that the expiration duration should be set to the expected minimum to avoid problems during syncing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, added

@lmossman lmossman requested a review from flash1293 July 27, 2023 23:33
Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@lmossman lmossman merged commit c542ceb into master Jul 31, 2023
@lmossman lmossman deleted the lmossman/session-token-auth-docs branch July 31, 2023 17:24
@Marcaccio-Mutt
Copy link

Hello!

Is this documentation updated? I dont find any example about "How configure Session Token"

@lmossman
Copy link
Contributor Author

lmossman commented Dec 6, 2023

@Marcaccio-Mutt you can find the session token authentication documentation for the Connector Builder here: https://docs.airbyte.com/connector-development/connector-builder-ui/authentication#session-token

@Marcaccio-Mutt
Copy link

Thx!

Is all this configuration inside the yaml file? Is there some example that how configure it?

@lmossman
Copy link
Contributor Author

lmossman commented Dec 6, 2023

@Marcaccio-Mutt That documentation is focused on explaining how to configure the session token authenticator in the Connector Builder UI, but the same ideas are applicable to the YAML manifest file as well (as the Connector Builder UI is just a layer on top of the YAML, and produces a low-code YAML manifest as output)

You can see an example of this in the source-dockerhub connector:

authenticator:
type: SessionTokenAuthenticator
login_requester:
type: HttpRequester
url_base: >-
https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/alpine:pull/
path: ""
authenticator:
type: NoAuth
http_method: GET
request_parameters: {}
request_headers: {}
request_body_json: {}
session_token_path:
- token
request_authentication:
type: ApiKey
inject_into:
type: RequestOption
field_name: Authorization
inject_into: header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants