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

Small change to allow easy support of multiple providers #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ruslantalpa
Copy link

This is a small change that allows configuring multiple oauth providers and serving them from the same location.

here is a sample

# initialize common oauth configuration
set $oauth_config_prefix '';
set $oauth_redirect_uri '_/oauth/callback';
set $oauth_success_uri '/';

# # google oauth configuration
set $google_redirect_uri "${oauth_redirect_uri}?provider=google";
set $google_success_uri "${oauth_success_uri}";
set $google_client_id '...';
set $google_client_secret '...';
set $google_authorization_url '...';
set $google_token_url '...';
set $google_userinfo_url '...';
set $google_scope '...';

# github oauth configuration
set $github_redirect_uri "${oauth_redirect_uri}?provider=github";
set $github_success_uri "${oauth_success_uri}";
set $github_client_id '...';
set $github_client_secret '...';
set $github_authorization_url '...';
set $github_token_url '...';
set $github_userinfo_url '...';
set $github_scope '...';


location /_oauth/login {
    set $oauth_config_prefix "${arg_provider}_";
    content_by_lua_file '../luajit/share/lua/5.1/ngx-oauth-login.lua';
}

PS: if you decide to merge this, please "squash" the commits for a cleaner history.
Thank you

This change allows to have multiple oauth2 provider configurations (each with it's own prefix) and still have single locations handling the auth flow where the right config prefix is decided at runtime based on some parameter
@ruslantalpa
Copy link
Author

just noticed the config is loaded only on the first request, then it's being cached (looking into it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant