Skip to content

150 auth0 developpement#151

Open
Pranxtor wants to merge 6 commits into
devfrom
150-auth0-developpement
Open

150 auth0 developpement#151
Pranxtor wants to merge 6 commits into
devfrom
150-auth0-developpement

Conversation

@Pranxtor
Copy link
Copy Markdown
Collaborator

  • Does not log the user out when changing pages or when a page is refreshed
  • Adds authentication to requests made from the front to the back
  • Checks that the user is logged into the application before using the backend on the data

@Pranxtor Pranxtor self-assigned this Jan 11, 2023
@Pranxtor Pranxtor linked an issue Jan 11, 2023 that may be closed by this pull request
3 tasks
@Pranxtor Pranxtor requested a review from sazulo January 13, 2023 10:51
@Pranxtor Pranxtor force-pushed the 150-auth0-developpement branch from 48cb243 to 046ec2d Compare January 16, 2023 11:03
return api
}

export const apiWithoutToken = axios.create({
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Si ce n'est plus utilisé, à enlever

Copy link
Copy Markdown
Collaborator Author

@Pranxtor Pranxtor Jan 16, 2023

Choose a reason for hiding this comment

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

c'est utilisé dans les tests


export const api = axios.create({
export async function useApi () {
const token = await client.value.getAccessTokenSilently()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Préfère un truc du genre:

  const auth0 = useAuth0()
  const api = axios.create({
    baseURL: process.env.VUE_APP_SERVER || 'http://localhost:3000',
    timeout: 60000,
    headers: {},
  })
  api.interceptors.request.use(async (config) => {
    const token = await auth0.getAccessTokenSilently()
    config.headers.Authorization = `Bearer ${token}`
  })
  return api

Copy link
Copy Markdown

Choose a reason for hiding this comment

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


export const client = ref(null)

export function exposeAuth0 () {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Je ne comprends pas a quoi sert ce plugin ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

c'est un plugin que j'ai créer pour pouvoir accéder à auth0 en dehors des components

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread ozkour-front/src/main.js
Comment on lines 12 to 19
createAuth0({
domain: process.env.VUE_APP_AUTH0_DOMAIN,
client_id: process.env.VUE_APP_AUTH0_CLIENT_ID,
redirect_uri: window.location.origin
redirect_uri: window.location.origin,
audience: process.env.VUE_APP_AUTH0_API_ID
})
)
).use(exposeAuth0())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Je ne comprends pas ca non plus. Selon la doc de auth0 :

app.use(
  createAuth0({
    domain: '<AUTH0_DOMAIN>',
    client_id: '<AUTH0_CLIENT_ID>',
    redirect_uri: '<MY_CALLBACK_URL>',
    audience: '<AUTH0_AUDIENCE>'
  })
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

c'est en lien avec le plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth0 developpement

2 participants