Class: Code0::Identities::Provider::Gitlab
- Inherits:
-
BaseOauth
- Object
- BaseOauth
- Code0::Identities::Provider::Gitlab
show all
- Defined in:
- lib/code0/identities/provider/gitlab.rb
Instance Attribute Summary
Attributes inherited from BaseOauth
#config_loader
Instance Method Summary
collapse
Methods inherited from BaseOauth
#initialize, #load_identity
Instance Method Details
#authorization_url ⇒ Object
27
28
29
30
31
|
# File 'lib/code0/identities/provider/gitlab.rb', line 27
def authorization_url
base_url + "/oauth/authorize?client_id=#{config[:client_id]}&response_type=code&redirect_uri=#{URI.encode_uri_component(config[:redirect_uri])}&scope=read_user"
end
|
#base_url ⇒ Object
7
8
9
|
# File 'lib/code0/identities/provider/gitlab.rb', line 7
def base_url
config[:base_url]
end
|
#create_identity(response) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/code0/identities/provider/gitlab.rb', line 33
def create_identity(response, *)
body = response.parsed_response
identifier = body["id"]
username = body["username"]
email = body["email"]
Identity.new(config_loader.call[:provider_name], identifier, username, email, nil, nil)
end
|
#token_payload(code) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/code0/identities/provider/gitlab.rb', line 15
def token_payload(code)
{ code: code,
grant_type: "authorization_code",
redirect_uri: config[:redirect_uri],
client_id: config[:client_id],
client_secret: config[:client_secret] }
end
|
#token_url ⇒ Object
11
12
13
|
# File 'lib/code0/identities/provider/gitlab.rb', line 11
def token_url
"#{base_url}/oauth/token"
end
|
#user_details_url ⇒ Object
23
24
25
|
# File 'lib/code0/identities/provider/gitlab.rb', line 23
def user_details_url
"#{base_url}/api/v4/user"
end
|