Casbin Forum runs on Casnode, the open-source Discourse-style forum. Try the Casnode demo →
Casbin Forum

Hey Guys,

i cannot manage to get this right. Wen setting response_type=code%20id_token

the login page is not rendering with the error "You need to enable JavaScript to run this app." Which does not to occur when just using code. i have tried various variations. The goal would be to recieve the id_token in my backend. I also tried with all kinds of scopes, knowing openid should be the one.

I also added all grant types in the application.

Does someone know whats going on? thx

2views
2users
1 minread

Thanks. I have looked into them. I know that i cloud just delete the sessionStorage als this example shows:
(https://github.com/casdoor/casdoor-raw-js-example/blob/master/index.html#L49)

function signOut() {
          sessionStorage.removeItem("token");
          window.location.href = "http://localhost:5000";
        }

but that does not affect the login state within casdoor.

I was trying something like:

router.get('/login', (req, res) => {

  const redirectUri = `${process.env.ENV_URL}/callback`;
  
  // using Standard-OAuth2 Flow
  const casdoorUrl = `${casdoorConfig.endpoint}/login/oauth/authorize?` +
  `client_id=${casdoorConfig.clientId}` +
  `&response_type=code token id_token` +
  `&redirect_uri=${encodeURIComponent(redirectUri)}` +
  `&scope=openid%20profile%20email`;

  res.redirect(casdoorUrl);
});

router.get('/logout', async (req, res) => {
  const idToken = ***;
  const redirectUri = process.env.ENV_URL;
  try {
    await axios.post(`${casdoorConfig.endpoint}/api/logout`, null, {
      params: {
        id_token_hint: idToken,
        post_logout_redirect_uri: redirectUri,
        state: 'my_state_value'
      }
    });
  } catch (error) {
    console.error('Logout-Error:', error);
  }
  req.session.destroy(() => {
    res.redirect(redirectUri);
  });
});

with &response_type=code token id_token i have tried a lot. Some times casdoor responds with not loading the login page. Sometimes i recieve the id_token as fragment. But i want the id_token param. wich doesnt work. 😢

I want to logout the user within all applications of the organisation. Or is this intended to be done different? Thanks!

1 / 5
Mar 2025