Module: Legion::Extensions::Github::App::Runners::Auth
- Includes:
- Helpers::Client, Helpers::Lex
- Included in:
- Client, Runners::Auth
- Defined in:
- lib/legion/extensions/github/app/runners/auth.rb
Constant Summary
Constants included from Helpers::Client
Helpers::Client::CREDENTIAL_RESOLVERS
Constants included from Helpers::TokenCache
Helpers::TokenCache::TOKEN_BUFFER_SECONDS
Instance Method Summary collapse
- #create_installation_token(jwt:, installation_id:) ⇒ Object
- #generate_jwt(app_id:, private_key:) ⇒ Object
- #get_installation(jwt:, installation_id:) ⇒ Object
- #list_installations(jwt:, per_page: 30, page: 1) ⇒ Object
Methods included from Helpers::Client
#connection, #gh_cli_token_output, #max_fallback_retries, #on_rate_limit, #on_scope_authorized, #on_scope_denied, #resolve_broker_app, #resolve_credential, #resolve_env, #resolve_gh_cli, #resolve_next_credential, #resolve_settings_app, #resolve_settings_delegated, #resolve_settings_pat, #resolve_vault_app, #resolve_vault_delegated, #resolve_vault_pat
Methods included from Helpers::ScopeRegistry
#credential_fingerprint, #invalidate_scope, #mark_rate_limited, #rate_limited?, #register_scope, #scope_status
Methods included from Helpers::TokenCache
#fetch_token, #mark_rate_limited, #rate_limited?, #store_token
Instance Method Details
#create_installation_token(jwt:, installation_id:) ⇒ Object
23 24 25 26 27 |
# File 'lib/legion/extensions/github/app/runners/auth.rb', line 23 def create_installation_token(jwt:, installation_id:, **) conn = connection(token: jwt, **) response = conn.post("/app/installations/#{installation_id}/access_tokens") { result: response.body } end |
#generate_jwt(app_id:, private_key:) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/github/app/runners/auth.rb', line 15 def generate_jwt(app_id:, private_key:, **) key = OpenSSL::PKey::RSA.new(private_key) now = Time.now.to_i payload = { iat: now - 60, exp: now + (10 * 60), iss: app_id.to_s } token = JWT.encode(payload, key, 'RS256') { result: token } end |
#get_installation(jwt:, installation_id:) ⇒ Object
35 36 37 38 39 |
# File 'lib/legion/extensions/github/app/runners/auth.rb', line 35 def get_installation(jwt:, installation_id:, **) conn = connection(token: jwt, **) response = conn.get("/app/installations/#{installation_id}") { result: response.body } end |
#list_installations(jwt:, per_page: 30, page: 1) ⇒ Object
29 30 31 32 33 |
# File 'lib/legion/extensions/github/app/runners/auth.rb', line 29 def list_installations(jwt:, per_page: 30, page: 1, **) conn = connection(token: jwt, **) response = conn.get('/app/installations', per_page: per_page, page: page) { result: response.body } end |