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

Restrict auth to specific Google groups #3

Open
woodie opened this issue Dec 1, 2021 · 0 comments
Open

Restrict auth to specific Google groups #3

woodie opened this issue Dec 1, 2021 · 0 comments

Comments

@woodie
Copy link
Owner

woodie commented Dec 1, 2021

When setting up restrict auth to specific Google groups from here it's not clear how actually create a service account.

Also, I can add scopes to the content screen but they don't show up as requested services and then the groups information is null.

services

consent

# /etc/nginx/conf.d/gollum.conf

        # pass information via X-Email headers to backend
        # requires running with --set-xauthrequest and --pass-access-token
        auth_request_set $name $upstream_http_x_auth_request_name;
        auth_request_set $user $upstream_http_x_auth_request_user;
        auth_request_set $email $upstream_http_x_auth_request_email;
        auth_request_set $groups $upstream_http_x_auth_request_groups;
        auth_request_set $language $upstream_http_x_auth_request_language;
        auth_request_set $token $upstream_http_x_auth_request_access_token;
        proxy_set_header X-Name $name;
        proxy_set_header X-User $user;
        proxy_set_header X-Email $email;
        proxy_set_header X-Groups $groups;
        proxy_set_header X-Language $language;
        proxy_set_header X-Access-Token $token;

# /etc/gollum/config.rb

class Precious::App
  before do
    name = request.get_header("HTTP_X_NAME") || request.env["X-Name"]
    user = request.get_header("HTTP_X_USER") || request.env["X-User"]
    email = request.get_header("HTTP_X_EMAIL") || request.env["X-Email"] || "[email protected]"
    groups = request.get_header("HTTP_X_GROUPS") || request.env["X-Groups"]
    language = request.get_header("HTTP_X_LANGUAGE") || request.env["X-Language"]
    debug = {name: name, user: user, email: email, groups: groups, language: language}.to_json
    File.write("/home/smeagol/debug.txt", debug)
    name = email.split("@").first
    halt 403, "Sorry, nothing for you here." unless @@authorized_users.include? name
    session["gollum.author"] = {name: name, email: email}
  end
end

# /home/smeagol/debug.txt 
{"name":null,"user":"106300570740248358559","email":"[email protected]","groups":null,"language":null}

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

No branches or pull requests

1 participant