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

feat: Password-less login with WebAuthn #195

Merged
merged 19 commits into from
Mar 25, 2023
Merged

feat: Password-less login with WebAuthn #195

merged 19 commits into from
Mar 25, 2023

Conversation

jay-dee7
Copy link
Member

@jay-dee7 jay-dee7 commented Oct 15, 2022

Instead of one large interface to cover for everything, we now have
multiple, smaller interfaces to make our backend more composable.
Refactor goes like this:

// Postgres Core
type PgTxnHandler interface {
    NewTxn(ctx context.Context) (pgx.Tx, error)
    Abort(ctx context.Context, txn pgx.Tx) error
    Commit(ctx context.Context, txn pgx.Tx) error
}

// User specific
type UserReader interface  {
    PgTxnHandler
    ...
}
type UserWriter interface  {
    PgTxnHandler
    ...
}
type UserDeleter interface  {
    PgTxnHandler
    ...
}
type UserReadWriteDeleter interface  {
    PgTxnHandler
    ...
}

// WebAuthn specific
type WebAuthn interface {
    PgTxnHandler
    UserReader
    UserWriter

    GetWebAuthNSessionData(ctx context.Context, userId string, sessionType string) (*webauthn.SessionData, error)
    AddWebAuthSessionData(ctx context.Context, userId string, sessionData *webauthn.SessionData, sessionType string) error
    GetWebAuthNCredentials(ctx context.Context, userId string) (*webauthn.Credential, error)
    AddWebAuthNCredentials(ctx context.Context, userId string, credential *webauthn.Credential) error
}

@jay-dee7 jay-dee7 force-pushed the web-authn branch 2 times, most recently from 16b1749 to 97bc9fd Compare October 15, 2022 13:03
@jay-dee7 jay-dee7 changed the title Web authn feat: Password-less login with WebAuthn Oct 16, 2022
@jay-dee7 jay-dee7 added this to the IPFS Milestone 1 milestone Oct 17, 2022
@jay-dee7 jay-dee7 mentioned this pull request Oct 17, 2022
@jay-dee7 jay-dee7 added enhancement New feature or request P1 P1 label is used for this that we see of highest priority. Critical bugs, security issues, etc Security Security enhancement related work labels Jan 7, 2023
@jay-dee7 jay-dee7 self-assigned this Jan 7, 2023
@jay-dee7 jay-dee7 force-pushed the web-authn branch 4 times, most recently from b09cfb4 to 86e70a3 Compare January 7, 2023 11:57
@jay-dee7 jay-dee7 force-pushed the web-authn branch 2 times, most recently from 0829802 to 64154d5 Compare February 5, 2023 16:26
@jay-dee7 jay-dee7 force-pushed the web-authn branch 2 times, most recently from 6ccd1a8 to 32faeec Compare February 18, 2023 13:42
@jay-dee7 jay-dee7 force-pushed the web-authn branch 4 times, most recently from 1e0f68c to d9e503e Compare March 18, 2023 15:25
@jay-dee7 jay-dee7 force-pushed the web-authn branch 7 times, most recently from 95fd0ec to e3917a8 Compare March 24, 2023 04:57
guacamole and others added 17 commits March 25, 2023 12:57
Signed-off-by: guacamole <gunjanwalecha@gmail.com>
Signed-off-by: jay-dee7 <jasdeepsingh.uppal@gmail.com>
Instead of one large interface to cover for everything, we now have
multiple, smaller interfaces to make our backend more composable.
Refactor goes like this:

```go
// Postgres Core
type PgTxnHandler interface {
    NewTxn(ctx context.Context) (pgx.Tx, error)
    Abort(ctx context.Context, txn pgx.Tx) error
    Commit(ctx context.Context, txn pgx.Tx) error
}

// User specific
type UserReader interface  {
    PgTxnHandler
    ...
}
type UserWriter interface  {
    PgTxnHandler
    ...
}
type UserDeleter interface  {
    PgTxnHandler
    ...
}
type UserReadWriteDeleter interface  {
    PgTxnHandler
    ...
}

// WebAuthn specific
type WebAuthn interface {
    PgTxnHandler
    UserReader
    UserWriter

    GetWebAuthNSessionData(ctx context.Context, userId string, sessionType string) (*webauthn.SessionData, error)
    AddWebAuthSessionData(ctx context.Context, userId string, sessionData *webauthn.SessionData, sessionType string) error
    GetWebAuthNCredentials(ctx context.Context, userId string) (*webauthn.Credential, error)
    AddWebAuthNCredentials(ctx context.Context, userId string, credential *webauthn.Credential) error
}
```
We have some utility methods in `auth` package which can be used in
different packages. We now make rewrite those methods as public
functions.
@jay-dee7 jay-dee7 marked this pull request as ready for review March 25, 2023 07:57
config.example.yaml Outdated Show resolved Hide resolved
store/postgres/queries/web_authn.go Outdated Show resolved Hide resolved
auth/auth.go Outdated Show resolved Hide resolved
Copy link
Member

@guacamole guacamole left a comment

Choose a reason for hiding this comment

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

Awesome work @jay-dee7 🥇 💯

@guacamole guacamole merged commit f026421 into main Mar 25, 2023
@guacamole guacamole deleted the web-authn branch March 25, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P1 P1 label is used for this that we see of highest priority. Critical bugs, security issues, etc Security Security enhancement related work
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

WebAuthN - Password-less and way more secure way of authentication and sharing critical information
2 participants