Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Dr. Doofenshmirtz
    @noelukwa_twitter
    no. the logs show 201, the browser agent and the request
    Lance Ivy
    @cainlevy
    it appears i was mistaken. there's no logging in authn for CORS failure. :/
    if it happens again, it'll be helpful to know how your APP_DOMAINS config is set for AuthN server
    hope it's fixed though! cheers ~
    Dr. Doofenshmirtz
    @noelukwa_twitter
    thanks..
    Dr. Doofenshmirtz
    @noelukwa_twitter
    hi @cainlevy , the authenjs package returns nothing for the sign up functio
    *function
    instead it stores the token in localstorage.. isnt there away to like get then token by attaching a .then method to the signup function?
    Lance Ivy
    @cainlevy
    @noelukwa_twitter yep! you can get the current token from Keratin.session(). it's important to read this only when you need it, because it will change frequently.
    Dr. Doofenshmirtz
    @noelukwa_twitter
    ahh! thanks..
    Dr. Doofenshmirtz
    @noelukwa_twitter
    how do i stop this ( http://localhost:8080/session 422 (Unprocessable Entity)) from logging to the browser console when request is unsuccesful
    Lance Ivy
    @cainlevy
    @noelukwa_twitter i'm not sure. it sounds like a logging thing outside of authn-js. are you catching rejected promises?
    Dr. Doofenshmirtz
    @noelukwa_twitter
    yes..
    i think the problem is coming from a 'throw"
    Lance Ivy
    @cainlevy
    Keratin.signup() returns a promise that may contain an error. if you do nothing to catch it, it will likely show up in your browser console. i recommend try{ await Keratin.signup(...) } catch (e) {...} if you're using async/await, or Keratin.signup().catch((e) => {...} if you prefer then/catch.
    Dr. Doofenshmirtz
    @noelukwa_twitter
    @cainlevy i fixed it.. i had a middleware somewhere logging errors..
    @cainlevy i am trying to get a full grasp of authn.. from the documentation.. authn should handle every thing about authentication.. so the only thing i should use for user validation on my backend is the token from authn. with i get with 'subjectfrom' ..
    or am i missing something?
    like how do i validate the user is authenticated ..
    Lance Ivy
    @cainlevy
    @noelukwa_twitter you've got it! the access token is their session, and you get their account id from there. if you're familiar with ruby on the backend then these examples might help: https://github.com/keratin/authn-rb/#example-sessions
    Dr. Doofenshmirtz
    @noelukwa_twitter
    i am using go
    Dr. Doofenshmirtz
    @noelukwa_twitter
    @cainlevy one final issue.. i am trying to open my api to other clients.. i am using ory/hydra to do the authorization.. but my api is protected with authn.. how do i connect hydra to get valid tokens from authn-server
    Dr. Doofenshmirtz
    @noelukwa_twitter
    i want user to be able to login with their credentials..
    and also third parties to be able to use my site on behalf of the user
    Dr. Doofenshmirtz
    @noelukwa_twitter
    @cainlevy
    Lance Ivy
    @cainlevy

    @noelukwa_twitter oh i'm very interested in your experience here! i've discussed ory/hydra with another authn user but my knowledge is only hypothetical.

    at present, i think you need to build your /login and /consent pages in your application. the login page should follow the normal login guide (https://keratin.github.io/authn-server/#/guide-implementing_login) and the consent page should follow normal session requirements.

    Dr. Doofenshmirtz
    @noelukwa_twitter
    i understand.. what i want to know is.. now my server will be protected by hydra
    how about those that log in with authn
    Lance Ivy
    @cainlevy
    hmm, is there a reason your app couldn't accept both hydra and authn tokens?
    feel free to DM me if there's more relevant detail
    Dr. Doofenshmirtz
    @noelukwa_twitter
    i am trying to figure out a way to check, if a request has either a valid authn token or a valid hydra token.. if none then return unauthorised error.
    Dr. Doofenshmirtz
    @noelukwa_twitter
    hello
    ????
    @cainlevy
    Lance Ivy
    @cainlevy
    yep, i've responded to your DM
    Matteo Poli
    @Urion_gitlab
    Hello, I have trouble setting up the auth server with keratin. I have created a docker-compose file similar to the one you can find on the keratin official repo. If I try to POST on http://localhost:8765/accounts with the correct json (username and password) keratin server return 422 error saying that username and password are missing.
    Lance Ivy
    @cainlevy
    Hmm, could you include an example of your POST?
    Matteo Poli
    @Urion_gitlab
    For sure
    curl --location --request POST 'http://localhost:8765/accounts' \ --header 'Content-Type: application/json' \ --header 'Origin: http://localhost:8765' \ --data-raw '{ "username": "Username", "password": "Password" }'
    I have some problems at the moment. For example, I can't find a guide on how to create database tables for keratin. Also, I tried to add "USERNAME_IS_EMAIL=true" in my .env file, inside the folder where I ran my docker compose. But It does not work
    version: '3'
    services:
      postgres:
        container_name: postgres_container
        image: postgres
        environment:
          POSTGRES_USER: ${POSTGRES_USER:-postgres}
          POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
          PGDATA: /data/postgres
        volumes:
          - postgres:/data/postgres
        ports:
          - "5432:5432"
        restart: unless-stopped
    
      redis:
        image: redis
    
      keratin:
        image: keratin/authn-server:latest
        ports:
          - "8765:3000"
        environment:
          DATABASE_URL: postgres://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB_NAME:-selfood}?sslmode=disable
          REDIS_URL: redis://redis:6379/0
          AUTHN_URL: http://authn:3000
          APP_DOMAINS: localhost
          SECRET_KEY_BASE: abcdef
        env_file:
          - .env
        depends_on:
          - redis
          - postgres
        healthcheck:
            test: ["CMD", "curl", "-f", "http://localhost:5432"]
            interval: 30s
            timeout: 10s
            retries: 5
    
    volumes:
      postgres:
    And this is my docker-compose file
    Matteo Poli
    @Urion_gitlab
    @cainlevy
    Lance Ivy
    @cainlevy

    @Urion_gitlab my apologies, I was away for a couple days.

    Also, I tried to add "USERNAME_IS_EMAIL=true" in my .env file, inside the folder where I ran my docker compose. But It does not work

    I know this one well enough. Docker will read a .env file but you must still tell it which ones to pass through to a container. Try adding - USERNAME_IS_EMAIL (with no value) inside the docker-compose.yml > services > keratin > environment stanza.

    edit: Actually I just noticed your env_file configuration. I haven't used that before, so I'm not sure if it has the same behavior that I'm describing. More here: https://docs.docker.com/compose/env-file/

    I can't find a guide on how to create database tables for keratin.

    Thanks for the feedback! I'll make a note on that. Meanwhile, what you need to do is create the database you want AuthN to use, then execute AuthN with the migrate command. With Docker Compose that might look like:

    docker-compose run --rm keratin ./authn migrate
    Lance Ivy
    @cainlevy
    @Urion_gitlab Ah-hah! AuthN isn't parsing the JSON body. This curl works:
    curl --location --header 'Origin: http://localhost:8765' \
        --request POST 'http://localhost:8765/accounts' \
        -F 'username=Username' \
        -F 'password=Password'
    Lance Ivy
    @cainlevy
    Matteo Poli
    @Urion_gitlab
    @cainlevy This means that I have to create a sql script?
    Matteo Poli
    @Urion_gitlab
    I can see from the logs that I've to create a specific database to make keratin works
    Also, I tried the GET /accounts/available passing as Content-Type application/json and it works correctly