Skip to content

Commit

Permalink
Remove baseURL where unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Nov 22, 2024
1 parent 87c761b commit 7d1550f
Showing 4 changed files with 10 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Sources/ImperialCore/Routing/FederatedServiceRouter.swift
Original file line number Diff line number Diff line change
@@ -54,10 +54,13 @@ public protocol FederatedServiceRouter: Sendable {
/// - Parameters:
/// - authURL: The URL for the route that will redirect the user to the OAuth provider.
/// - authenticateCallback: Execute custom code within the authenticate closure before redirection.
/// - router: The router to configure the routes on.
/// - Throws: N/A
func configureRoutes(
withAuthURL authURL: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, on router: some RoutesBuilder)
throws
withAuthURL authURL: String,
authenticateCallback: (@Sendable (Request) async throws -> Void)?,
on router: some RoutesBuilder
) throws

/// Gets an access token from an OAuth provider.
/// This method is the main body of the `callback` handler.
3 changes: 1 addition & 2 deletions Sources/ImperialDiscord/DiscordRouter.swift
Original file line number Diff line number Diff line change
@@ -2,12 +2,11 @@ import Foundation
import Vapor

final public class DiscordRouter: FederatedServiceRouter {
public static let baseURL: String = "https://discord.com/"
public let tokens: any FederatedServiceTokens
public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable
public let scope: [String]
public let callbackURL: String
public let accessTokenURL: String = "\(DiscordRouter.baseURL.finished(with: "/"))api/oauth2/token"
public let accessTokenURL: String = "https://discord.com/api/oauth2/token"
public let service: OAuthService = .discord
public let callbackHeaders = HTTPHeaders([("Content-Type", "application/x-www-form-urlencoded")])

3 changes: 1 addition & 2 deletions Sources/ImperialGitHub/GitHubRouter.swift
Original file line number Diff line number Diff line change
@@ -2,12 +2,11 @@ import Foundation
import Vapor

final public class GitHubRouter: FederatedServiceRouter {
public static let baseURL: String = "https://github.com/"
public let tokens: any FederatedServiceTokens
public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable
public let scope: [String]
public let callbackURL: String
public let accessTokenURL: String = "\(GitHubRouter.baseURL.finished(with: "/"))login/oauth/access_token"
public let accessTokenURL: String = "https://github.com/login/oauth/access_token"
public let service: OAuthService = .github
public let callbackHeaders: HTTPHeaders = {
var headers = HTTPHeaders()
6 changes: 3 additions & 3 deletions Sources/ImperialGitlab/GitlabRouter.swift
Original file line number Diff line number Diff line change
@@ -2,12 +2,11 @@ import Foundation
import Vapor

final public class GitlabRouter: FederatedServiceRouter {
public static let baseURL: String = "https://gitlab.com/"
public let tokens: any FederatedServiceTokens
public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable
public let scope: [String]
public let callbackURL: String
public let accessTokenURL: String = "\(GitlabRouter.baseURL.finished(with: "/"))oauth/token"
public let accessTokenURL: String = "https://gitlab.com/oauth/token"
public let service: OAuthService = .gitlab

public required init(
@@ -44,6 +43,7 @@ final public class GitlabRouter: FederatedServiceRouter {
clientSecret: tokens.clientSecret,
code: code,
grantType: "authorization_code",
redirectUri: self.callbackURL)
redirectUri: self.callbackURL
)
}
}

0 comments on commit 7d1550f

Please sign in to comment.