https://supertokens.com/ logo
Docs
Join the conversationJoin Discord
Channels
community
contributing
general
github-activity
info
introductions
new-releases
random
security
support-questions
welcome-0xdelusion
welcome-aj-ya
welcome-aleksandrc
welcome-alpinjs
welcome-amberlamps1
welcome-andrew-rodriguez
welcome-ankit-choudhary
welcome-anthony-stod-custodio
welcome-call-in
welcome-chwalbox
welcome-claybiokiller
welcome-co7e
welcome-cosmoecwsa
welcome-devdag
welcome-dinso
welcome-drebotelho
welcome-elio
welcome-ernest
welcome-foxbarrington
welcome-fromscratch
welcome-galto4ir
welcome-goetzum
welcome-hay-kot
welcome-himanshu-kukreja
welcome-hossambarakat
welcome-ichikawakazuto
welcome-jahir9991
welcome-jamesl
welcome-jerry123424
welcome-john-oliver
welcome-jonas-alexanderson
welcome-jxyz
welcome-kelvinwop
welcome-kraz
welcome-lancekey
welcome-leoo
welcome-lukeacollins
welcome-m-j-mon
welcome-malik-khoja
welcome-marco
welcome-mardadi
welcome-meshguy
welcome-metamorph
welcome-mike-tectu
welcome-mirzok
welcome-mozomig
welcome-naberyou66_
welcome-nacer
welcome-namratha
welcome-naveenkumar
welcome-nightlight
welcome-nischith
welcome-notankit
welcome-olawumi
welcome-pavan-kumar-reddy-n
welcome-pineappaul
welcome-poothebear
welcome-rick
welcome-samuel-qosenergy
welcome-samuelstroschein
welcome-shubhamgoel23
welcome-shubhamkaushal
welcome-sidebar
welcome-surajsli
welcome-suyash_
welcome-syntaxerror
welcome-tauno
welcome-tauno
welcome-tawnoz
welcome-teclali
welcome-tls
welcome-turbosepp
welcome-vikram_shadow
welcome-yann
Powered by Linen
general
  • r

    repomaa

    04/12/2021, 10:04 AM
    i know, it's not optimal, but it would simplify verification for systems, that already support jwt verification
  • r

    rp

    04/12/2021, 10:05 AM
    The JWT signing keys are managed by supertokens itself: - A public / private key is generated and stored in the db. The public key is used to verify - The keys are changed on a regular basis for improved security. So at the moment, you can't set on global key unfortunately.
  • r

    repomaa

    04/12/2021, 10:06 AM
    mh ok
  • r

    rp

    04/12/2021, 10:06 AM
    But if we were to add this feature, how would that work?
  • r

    repomaa

    04/12/2021, 10:06 AM
    i'd expect you'd be able to pass the token as an env var
  • r

    repomaa

    04/12/2021, 10:06 AM
    or docker secret
  • r

    repomaa

    04/12/2021, 10:06 AM
    *key
  • r

    rp

    04/12/2021, 10:06 AM
    A public private key you mean?
  • r

    repomaa

    04/12/2021, 10:07 AM
    hopefully a private private key 😄
  • r

    rp

    04/12/2021, 10:07 AM
    what do you mean by private private key?
  • r

    rp

    04/12/2021, 10:07 AM
    So the signing algo is RSA256
  • r

    repomaa

    04/12/2021, 10:07 AM
    yeah so then you'd pass the private rsa key
  • r

    rp

    04/12/2021, 10:07 AM
    which means a private key is used to sign the token, and a public key is used to verify the token
  • r

    repomaa

    04/12/2021, 10:07 AM
    yeah
  • r

    rp

    04/12/2021, 10:07 AM
    So you would have to pass a private and a public key
  • r

    repomaa

    04/12/2021, 10:08 AM
    you can derive the pub key from the private key
  • r

    rp

    04/12/2021, 10:08 AM
    Actually, there is a way to do this now
  • r

    rp

    04/12/2021, 10:08 AM
    One min
  • r

    repomaa

    04/12/2021, 10:08 AM
    there is?
  • r

    repomaa

    04/12/2021, 10:08 AM
    that'd be great
  • r

    rp

    04/12/2021, 10:16 AM
    So it is a little cumbersome, but you can do the following: - Switch off JWT signing key rotation: https://supertokens.io/docs/session/common-customizations/sessions/jwt-signing-key-rotation (set
    ACCESS_TOKEN_SIGNING_KEY_DYNAMIC
    to
    false
    ) - Go to the database >
    key_value
    table > change the value of
    "access_token_signing_key"
    to ;. For example, if the public key is "pubkey" and private key is "prikey", then the value in the db should be "pubkey;prikey". The way we generate public and private keys can be seen here: https://github.com/supertokens/supertokens-core/blob/master/src/main/java/io/supertokens/utils/Utils.java#L189
  • r

    rp

    04/12/2021, 10:18 AM
    Note that this will enable you to set a global public key to verify the access token from the user. However, the access token's (not the same as an ID token) payload is not that of a standard JWT, so it also depends on what you want to do with the access token once it's signature is verified
  • r

    repomaa

    04/12/2021, 10:19 AM
    ah it's not?
  • r

    repomaa

    04/12/2021, 10:19 AM
    what does the payload look like?
  • r

    repomaa

    04/12/2021, 10:20 AM
    would be great if it would contain the userId
  • r

    repomaa

    04/12/2021, 10:20 AM
    what format is
    <public key>;<private key>
    pem? JWK?
  • r

    rp

    04/12/2021, 10:23 AM
    The payload we have has the following: - `sessionHandle`: A constant ID per session. -
    userId
    - `refreshTokenHash1`: a reference to this token's refresh token - `parentRefreshTokenHash1`: a reference to the refresh token that was used to create this access token. - `userData`: Any JSON object that you wish to provide - `antiCsrfToken`: used to check if the incoming anti-csrf token is valid or not - `expiryTime`: in Milliseconds - `timeCreated`: in Milliseconds - `lmrt`: Used to check when the user had last manually authenticated
  • r

    repomaa

    04/12/2021, 10:23 AM
    well that's totally fine
  • r

    repomaa

    04/12/2021, 10:24 AM
    userData could contain roles or what not. Should be enough to do authorization based on the payload
  • r

    rp

    04/12/2021, 10:25 AM
    > what format is ; pem? JWK? Yes .pem format, but without the
    -----BEGIN PUBLIC KEY-----
    and
    -----END PUBLIC KEY-----
    parts
Powered by Linen
Title
r

rp

04/12/2021, 10:25 AM
> what format is ; pem? JWK? Yes .pem format, but without the
-----BEGIN PUBLIC KEY-----
and
-----END PUBLIC KEY-----
parts
View count: 1