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

fix: redirectUri being added a port on windows platform #92

Open
Unreal22 opened this issue Jun 18, 2024 · 2 comments
Open

fix: redirectUri being added a port on windows platform #92

Unreal22 opened this issue Jun 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Unreal22
Copy link

Unreal22 commented Jun 18, 2024

Hi, I'm not sure if this is a issue, or if I'm missing a config, but whenever I try to use this on windows, the Uri gets changed, and in Chrome as web works fine.

final manager = OidcUserManager.lazy(
store: OidcMemoryStore(),
settings: OidcUserManagerSettings(redirectUri: Uri.parse("com.okta.dev-41706738:/callback")),
clientCredentials:const OidcClientAuthentication.clientSecretBasic(clientId: "0oahre9v3cQmMQ3BR5d7",
clientSecret: "cT4PozCQcBYtE1MG_36qjDQGYjdLQeu5tohr0aStjuZo2J96bymtxYJ-kaI8Ce0w",),
discoveryDocumentUri: OidcUtils.getOpenIdConfigWellKnownUri(Uri.parse("https://dev-41706738-admin.okta.com"),),);

Chrome: redirect_uri=com.okta.dev-41706738%3A%2Fcallback (Good one)
Windows: redirect_uri=com.okta.dev-41706738%3A%2F%2F%3A53856%2Fcallback (Changed one)

I'm using the example Git repo, didn't really changed any setting, and I'm using the same example that comes with the package.

Thanks a lot!

@Unreal22 Unreal22 added the bug Something isn't working label Jun 18, 2024
@ahmednfwela
Copy link
Member

We are using https://datatracker.ietf.org/doc/html/rfc8252 to handle desktop auth

and there are 3 ways to receive the auth response

The redirect url you used suggests you are using the first method "Private-Use URI Scheme Redirection", which is actually less secure.

This is why we only support the third method (Loopback Interface Redirection) as it does not require any custom configuration regarding DNS or messing with domain claims.

our example app contains a sample code on how to configure a cross-platform redirect uri:

postLogoutRedirectUri: kIsWeb
? Uri.parse('http://localhost:22433/redirect.html')
: Platform.isAndroid || Platform.isIOS || Platform.isMacOS
? Uri.parse('com.bdayadev.oidc.example:/endsessionredirect')
: Platform.isWindows || Platform.isLinux
? Uri.parse('http://localhost:0')
: null,
redirectUri: kIsWeb
// this url must be an actual html page.
// see the file in /web/redirect.html for an example.
//
// for debugging in flutter, you must run this app with --web-port 22433
? Uri.parse('http://localhost:22433/redirect.html')
: Platform.isIOS || Platform.isMacOS || Platform.isAndroid
// scheme: reverse domain name notation of your package name.
// path: anything.
? Uri.parse('com.bdayadev.oidc.example:/oauth2redirect')
: Platform.isWindows || Platform.isLinux
// using port 0 means that we don't care which port is used,
// and a random unused port will be assigned.
//
// this is safer than passing a port yourself.
//
// note that you can also pass a path like /redirect,
// but it's completely optional.
? Uri.parse('http://localhost:0')
: Uri(),

@ahmednfwela
Copy link
Member

After doing some research around okta provider, it seems that it's a limitation with okta: https://devforum.okta.com/t/loopback-interface-redirection-ephemeral-ports-wildcard-ports-in-localhost-redirect-uri/22197/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants