Skip to content

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.

1 participant