-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Code0 | ||
module Identities | ||
VERSION: String | ||
class Error < StandardError end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Code0 | ||
module Identities | ||
class Identity < Struct[String] | ||
attr_reader provider: Symbol | ||
attr_reader identitfier: String | ||
attr_reader username: String? | ||
attr_reader email: String? | ||
attr_reader firstname: String? | ||
attr_reader lastname: String? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Code0 | ||
module Identities | ||
class IdentityProvider | ||
attr_reader providers: Array[Provider::BaseOauth] | ||
|
||
def initialize: () -> void | ||
|
||
def add_provider: (provider_type: Symbol, config: Proc | Hash[Symbol, any]) -> void | ||
|
||
def add_named_provider: (provider_id: Symbol, provider_type: Symbol, config: Proc | Hash[Symbol, any]) -> void | ||
|
||
def load_identity: (provider_id: Symbol, params: Hash[Symbol, any]) -> Identity | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Code0 | ||
module Identities | ||
module Provider | ||
class BaseOauth | ||
attr_reader config_loader: Proc | Hash[Symbol, any] | ||
|
||
def initialize: (config_loader: Proc | Hash[Symbol, any]) -> void | ||
|
||
def authorization_url: () -> String | ||
|
||
def token_url: () -> String | ||
|
||
def user_details_url: () -> String | ||
|
||
def config: () -> Hash[Symbol, any] | ||
|
||
def create_identity: (response: Net::HTTPResponse, token: String, token_type: String) -> Identity | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Code0 | ||
module Identities | ||
module Provider | ||
class Discord < BaseOauth | ||
def token_url: () -> "https://discord.com/api/oauth2/token" | ||
|
||
def token_payload: (untyped code) -> { code: String, grant_type: "authorization_code", redirect_uri: String, client_id: String, client_secret: String } | ||
|
||
def user_details_url: () -> "https://discord.com/api/users/@me" | ||
|
||
def authorization_url: () -> String | ||
|
||
def create_identity: (response: Net::HTTPResponse) -> Identity | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Code0 | ||
module Identities | ||
module Provider | ||
class Github < BaseOauth | ||
def token_url: () -> "https://github.com/login/oauth/access_token" | ||
|
||
def token_payload: (code: String) -> { code: String, redirect_uri: String, client_id: String, client_secret: String } | ||
|
||
def user_details_url: () -> "https://api.github.com/user" | ||
|
||
def authorization_url: () -> ::String | ||
|
||
def private_email: (access_token: String, token_type: String) -> String | ||
|
||
def create_identity: (response: Net::HTTPResponse, access_token: String, token_type: String) -> Identity | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Code0 | ||
module Identities | ||
module Provider | ||
class Gitlab < BaseOauth | ||
def base_url: () -> String | ||
|
||
def token_url: () -> ::String | ||
|
||
def token_payload: (code: String) -> { code: String, grant_type: "authorization_code", redirect_uri: String, client_id: String, client_secret: String } | ||
|
||
def user_details_url: () -> ::String | ||
|
||
def authorization_url: () -> String | ||
|
||
def create_identity: (response: Net::HTTPResponse) -> Identity | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Code0 | ||
module Identities | ||
module Provider | ||
class Google < BaseOauth | ||
def base_url: () -> "https://accounts.google.com" | ||
|
||
def token_url: () -> "https://oauth2.googleapis.com/token" | ||
|
||
def token_payload: (code: String) -> { code: String, grant_type: "authorization_code", redirect_uri: String, client_id: String, client_secret: String } | ||
|
||
def user_details_url: () -> "https://www.googleapis.com/oauth2/v3/userinfo" | ||
|
||
def authorization_url: () -> String | ||
|
||
def create_identity: (response: Net::HTTPResponse) -> Identity | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Code0 | ||
module Identities | ||
module Provider | ||
class Microsoft < BaseOauth | ||
def base_url: () -> "https://graph.microsoft.com/" | ||
|
||
def token_url: () -> "https://login.microsoftonline.com/consumers/oauth2/v2.0/token" | ||
|
||
def token_payload: (code: String) -> { code: String, grant_type: "authorization_code", redirect_uri: String, client_id: String, client_secret: String } | ||
|
||
def user_details_url: () -> "https://graph.microsoft.com/oidc/userinfo" | ||
|
||
def create_identity: (response: Net::HTTPResponse) -> Identity | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Code0 | ||
module Identities | ||
VERSION: String | ||
end | ||
end |