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

feat(auth): Removed dependency on oauth2 token for refreshToken and move to initiateAuth for hostedUI #3497

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,19 @@ extension RefreshSessionState {
case .notStarted:

if case .refreshCognitoUserPool(let signedInData) = event.isRefreshSessionEvent {
if case .hostedUI = signedInData.signInMethod {
let action = RefreshHostedUITokens(existingSignedIndata: signedInData)
return .init(newState: .refreshingUserPoolToken(signedInData),
actions: [action])
} else {
let action = RefreshUserPoolTokens(existingSignedIndata: signedInData)
return .init(newState: .refreshingUserPoolToken(signedInData),
actions: [action])
}
let action = RefreshUserPoolTokens(existingSignedIndata: signedInData)
return .init(newState: .refreshingUserPoolToken(signedInData),
actions: [action])
}

if case .refreshCognitoUserPoolWithIdentityId(
let signedInData,
let identityID) = event.isRefreshSessionEvent {

if case .hostedUI = signedInData.signInMethod {
let action = RefreshHostedUITokens(existingSignedIndata: signedInData)
return .init(
newState: .refreshingUserPoolTokenWithIdentity(signedInData,
identityID),
actions: [action])
} else {
let action = RefreshUserPoolTokens(existingSignedIndata: signedInData)
return .init(newState:
.refreshingUserPoolTokenWithIdentity(signedInData, identityID),
actions: [action])
}
let action = RefreshUserPoolTokens(existingSignedIndata: signedInData)
return .init(newState:
.refreshingUserPoolTokenWithIdentity(signedInData, identityID),
actions: [action])

}
if case .refreshUnAuthAWSCredentials(let identityID) = event.isRefreshSessionEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,36 +120,6 @@ struct HostedUIRequestHelper {
return urlRequest
}

static func createRefreshTokenRequest(
refreshToken: String,
configuration: HostedUIConfigurationData) throws -> URLRequest {

var components = URLComponents()
components.scheme = "https"
components.path = "/oauth2/token"
components.host = configuration.oauth.domain

guard let url = components.url else {
throw HostedUIError.tokenURI
}

var queryComponents = URLComponents()
queryComponents.queryItems = [
.init(name: "grant_type", value: "refresh_token"),
.init(name: "refresh_token", value: refreshToken),
.init(name: "client_id", value: configuration.clientId)]

guard let body = queryComponents.query else {
throw HostedUIError.tokenURI
}

var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "POST"
urlRequest.httpBody = Data(body.utf8)
urlRequest.addHeaders(using: configuration)
return urlRequest
}

static func urlSafeBase64(_ content: String) -> String {
return content.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "+", with: "-")
Expand Down
Loading
Loading