ngx-oauth icon indicating copy to clipboard operation
ngx-oauth copied to clipboard

Small change to allow easy support of multiple providers

Open ruslantalpa opened this issue 3 years ago • 1 comments

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

ruslantalpa avatar Jan 28 '21 08:01 ruslantalpa

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

ruslantalpa avatar Jan 28 '21 08:01 ruslantalpa