Adding Custom Auth

I am looking to add LinkedIn auth to an existing wasp project. Specifically, the linkedin auth that request the user's profile (3-legged oauth). How would I go about this? I know that it might involve modifying the wasp managed Auth entities but I can't find resources on doing that. Thanks in advance for your help!
8 Replies
kapa.ai
kapa.ai6mo ago
Hi @Connor. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not include specific information on how to add LinkedIn authentication to a Wasp project. However, Wasp does support other social login providers like Google, GitHub, and Keycloak, and the process might be similar. In general, adding social login to a Wasp project involves several steps: 1. Enabling the social authentication in the Wasp file. 2. Adding the User entity. 3. Creating a client for the social provider. 4. Adding the necessary Routes and Pages. 5. Using Auth UI components in your Pages. Here is a skeleton of how your main.wasp should look like after you're done:
// Configuring the social authentication
app myApp {
auth: { ... }
}

// Defining entities
entity User { ... }

// Defining routes and pages
route LoginRoute { ... }
page LoginPage { ... }
// Configuring the social authentication
app myApp {
auth: { ... }
}

// Defining entities
entity User { ... }

// Defining routes and pages
route LoginRoute { ... }
page LoginPage { ... }
You can find more details in the Wasp documentation (https://wasp-lang.dev/docs/auth/social-auth/overview). As for modifying the Wasp managed Auth entities, the documentation states that the Auth, AuthIdentity, and Session entities are created behind the scenes and are used to store the user's login credentials. You as the developer don't need to care about these entities most of the time. Wasp owns these entities. In the case you want to create a custom signup action, you will need to use the Auth and AuthIdentity entities directly. You can find more information in the Wasp documentation (https://wasp-lang.dev/docs/auth/entities#entities-explained). I recommend reaching out to the Wasp community or checking their documentation for more specific guidance on adding LinkedIn authentication. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Connor, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Connor
ConnorOP6mo ago
@kapa.ai How would I go about modifying these wasp Auth Entities? @kapa.ai How would I go about modifying these wasp Auth Entities?
kapa.ai
kapa.ai6mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- In Wasp, the Auth, AuthIdentity, and Session entities are created behind the scenes and are used to store the user's login credentials. These entities are owned by Wasp, and you as the developer don't need to care about these entities most of the time. However, if you want to create a custom signup action, you will need to use the Auth and AuthIdentity entities directly. For example, Wasp's internal Auth entity is used to connect the business logic user, User with the user's login credentials. Here is how it looks:
entity Auth {=psl
id String @id @default(uuid())
userId Int? @unique
// Wasp injects this relation on the User entity as well
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
identities AuthIdentity[]
sessions Session[]
psl=}
entity Auth {=psl
id String @id @default(uuid())
userId Int? @unique
// Wasp injects this relation on the User entity as well
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
identities AuthIdentity[]
sessions Session[]
psl=}
The Auth fields: - id is a unique identifier of the Auth entity. - userId is a foreign key to the User entity. It is used to connect the Auth entity with the business logic user. - user is a relation to the User entity. This relation is injected on the User entity as well. - identities is a relation to the AuthIdentity entity. - sessions is a relation to the Session entity. You can find more information in the Wasp documentation (https://wasp-lang.dev/docs/auth/entities#auth-entity-). As for the User entity, you own this entity and you can modify it as you wish. You can add new fields to it, remove fields from it, or change the type of the fields. You can also add new relations to it or remove existing relations from it. Here is an example of how you can define a User entity:
entity User {=psl
id Int @id @default(autoincrement())
// Any other fields you want to store about the user
psl=}
entity User {=psl
id Int @id @default(autoincrement())
// Any other fields you want to store about the user
psl=}
You can find more information in the Wasp documentation (https://wasp-lang.dev/docs/auth/entities#entities-explained). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Connor, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Connor
ConnorOP6mo ago
@kapa.ai How can the auth entities be modified?
MEE6
MEE66mo ago
Wohooo @Connor, you just became a Waspeteer level 1!
kapa.ai
kapa.ai6mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- In Wasp, the Auth, AuthIdentity, and Session entities are managed by Wasp and are used to store the user's login credentials. These entities are owned by Wasp, and you as the developer don't need to care about these entities most of the time. However, if you want to create a custom signup action, you will need to use the Auth and AuthIdentity entities directly. But, there is no direct way to modify these entities as they are managed by Wasp itself. As for the User entity, you own this entity and you can modify it as you wish. You can add new fields to it, remove fields from it, or change the type of the fields. You can also add new relations to it or remove existing relations from it. Here is an example of how you can define a User entity:
entity User {=psl
id Int @id @default(autoincrement())
// Any other fields you want to store about the user
psl=}
entity User {=psl
id Int @id @default(autoincrement())
// Any other fields you want to store about the user
psl=}
You can find more information in the Wasp documentation (https://wasp-lang.dev/docs/auth/entities#entities-explained). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Connor, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Paryan
Paryan6mo ago
I don't think you can modify the auth entities themself @Connor . And I do not think that Wasp allows you to use LinkedIn Auth directly (at least the version that you want). Maybe someone else knows because this is a question I have too. @Wasp Team @Wasp Expert
martinsos
martinsos6mo ago
Yup @Paryan you answered this correctly! Working on this, will be having it in a couple of months most likely (LinkedIn and more other providers, likely including adding custom provider), but for now you can't add it on your own.
Want results from more Discord servers?
Add your server