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

Add different authentication modes to JS SDK #3599

Closed
kschiffer opened this issue Dec 17, 2020 · 0 comments · Fixed by #3601
Closed

Add different authentication modes to JS SDK #3599

kschiffer opened this issue Dec 17, 2020 · 0 comments · Fixed by #3601
Assignees
Labels
c/sdk/js This is related to the JavaScript SDK in progress We're working on it technical debt Not necessarily broken, but could be done better/cleaner
Milestone

Comments

@kschiffer
Copy link
Member

Summary

Since #2564, we allow authorization by session cookie. The SDK does however not support this new authentication mode. This should be added.

Why do we need this?

To use the JS SDK with a session cookie for authentication, e.g. for the account app (#1422).

What is already there? What do you see now?

  • SDK support for authentication via Bearer token (API Key or access token)
  • The stack supporting authentication using a session cookie

What is missing? What do you want to see?

Possibility to configure the SDK to use the session cookie (in conjunction with a CSRF token) for authentication.

How do you propose to implement this?

Currently, the constructor signature for the SDK client class is TtnLw(token, options)

  1. The class name should be updated to TTS()
  2. We should use the options object pattern and use a single argument for the constructor:
// For key authentication
const ttsClient = new TTS({
  authentication: {
    mode: 'token',
    key: token,
  },
  stackConfig: config,})

// For session authentication
const ttsClient = new TTS({
  authentication: {
    mode: 'session',
    csrfToken: csrf,
  },
  stackConfig: config,})

How do you propose to test this?

Update unit tests and manual testing. Any issue here should also be caught by our e2e's.

Can you do this yourself and submit a Pull Request?

Yes.

@kschiffer kschiffer added in progress We're working on it technical debt Not necessarily broken, but could be done better/cleaner c/sdk/js This is related to the JavaScript SDK labels Dec 17, 2020
@kschiffer kschiffer added this to the December 2020 milestone Dec 17, 2020
@kschiffer kschiffer self-assigned this Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/sdk/js This is related to the JavaScript SDK in progress We're working on it technical debt Not necessarily broken, but could be done better/cleaner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant