Skipping the Consent Dialog #1307
Replies: 4 comments 4 replies
-
|
I have not been able to get this working yet I get this error |
Beta Was this translation helpful? Give feedback.
-
|
@panva How can i disable consent form if my application is native |
Beta Was this translation helpful? Give feedback.
-
|
@panva Thanks for the tutorial — it works well for the general use case of base scopes. However, for first-party applications, it's also important to be able to skip the consent screen when requesting refresh tokens. Currently, the implementation in check_scope automatically filters out the Moreover, this logic makes it impossible for developers to even detect that the I’d prefer a solution where the provider doesn’t modify the originally requested scopes, and instead works it out it's own way at the end when creating the grants. This would give developers access to the full original request and they can make an informed decision within the |
Beta Was this translation helpful? Give feedback.
-
|
For others.. in my case it wasn't enough to only tamper the
import { Provider, interactionPolicy } from 'oidc-provider';
import type { Configuration, Client } from 'oidc-provider';
const basePolicy = interactionPolicy.base();
const Check = interactionPolicy.Check;
const consentPrompt = basePolicy.get('consent');
const isTrusted = (client?: Client) => client && client['trusted'] != null && client['trusted'] === true;
if (consentPrompt) {
const consentCheck = consentPrompt.checks.get('consent_prompt');
if (consentCheck) {
consentCheck.check = (ctx) => {
const { oidc } = ctx;
const client = oidc.client;
if (!oidc.prompts.has('consent')) {
return Check.NO_NEED_TO_PROMPT;
}
if ((!isTrusted(client) && !oidc.result?.consent) || oidc.promptPending('consent')) {
return Check.REQUEST_PROMPT;
}
return Check.NO_NEED_TO_PROMPT;
};
}
const nativeClientCheck = consentPrompt.checks.get('native_client_prompt');
if (nativeClientCheck) {
nativeClientCheck.check = (ctx) => {
const { oidc } = ctx;
const client = oidc.client;
if (isTrusted(client)) {
return Check.NO_NEED_TO_PROMPT;
}
// Original logic for non-trusted clients
if (
client &&
client.applicationType === 'native' &&
oidc.params &&
oidc.params.response_type !== 'none' &&
!oidc.result?.consent
) {
return Check.REQUEST_PROMPT;
}
return Check.NO_NEED_TO_PROMPT;
};
}
}note: the logic might be improved, haven't run into edge-cases yet. Reasoning: as previous conversations in this thread mentioned, asking for a refresh_token is done by conforming to 3 conditions:
Rewriting the However, using the prompt=consent will still trigger the need to show the consent screen because the original request explicitly used If your client is also a native client then you also have to edit the -> After all these, you can finally skip the consent screen for trusted (first-party) clients. I hope this helps someone. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note
Author: @panva
Target version: ^9.0.0
Warning
Sometimes your use-case doesn't need a consent screen.
This might occur if the authorization server has only first-party clients configured. To achieve that you want to add the requested claims/scopes/resource scopes to the grant:
This will get you as far as not asking for any consent unless the application is a native application (e.g. iOS, Android, CLI, Device Flow). It is recommended to still show a consent screen to those with the application details to those since they are public clients and their redirect_uri ownership can rarely be validated.
Beta Was this translation helpful? Give feedback.
All reactions