-
Notifications
You must be signed in to change notification settings - Fork 474
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
Move Session Storage to shopify_app
#1055
Conversation
shopify_app
Co-authored-by: Andy Waite <[email protected]>
Co-authored-by: Andy Waite <[email protected]>
Co-authored-by: Andy Waite <[email protected]>
@@ -17,12 +19,14 @@ class << self | |||
).returns(T.nilable(Auth::Session)) | |||
end | |||
def load_current_session(auth_header: nil, cookies: nil, is_online: false) | |||
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.load_current_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now owns this responsiblity.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need these now that we have the check in Context
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also - extra space before 'will')
lib/shopify_api/context.rb
Outdated
@@ -69,6 +69,11 @@ def setup( | |||
@scope = Auth::AuthScopes.new(scope) | |||
@is_embedded = is_embedded | |||
@session_storage = session_storage | |||
if @session_storage | |||
# rubocop:disable Layout/LineLength | |||
::ShopifyAPI::Context.logger.warn("SessionStorage has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now owns this responsiblity.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::ShopifyAPI::Context.logger.warn("SessionStorage has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now owns this responsiblity.") | |
::ShopifyAPI::Context.logger.warn("SessionStorage has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now implements this responsibility.") |
@@ -33,10 +37,12 @@ def load_current_session(auth_header: nil, cookies: nil, is_online: false) | |||
).returns(T::Boolean) | |||
end | |||
def delete_current_session(auth_header: nil, cookies: nil, is_online: false) | |||
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.delete_current_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now owns this responsiblity.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.delete_current_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now owns this responsiblity.") | |
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.delete_current_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now implements this responsibility.") |
@@ -46,8 +52,10 @@ def delete_current_session(auth_header: nil, cookies: nil, is_online: false) | |||
).returns(T.nilable(Auth::Session)) | |||
end | |||
def load_offline_session(shop:, include_expired: false) | |||
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.load_offline_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now owns this responsiblity.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.load_offline_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now owns this responsiblity.") | |
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.load_offline_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now implements this responsibility.") |
unless Context.private_shop | ||
raise Errors::SessionNotFoundError, "Could not load private shop, Context.private_shop is nil." | ||
end | ||
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.delete_offline_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now owns this responsiblity.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.delete_offline_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now owns this responsiblity.") | |
::ShopifyAPI::Context.logger.warn("ShopifyAPI::Utils::SessionUtils.delete_offline_session has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Consider using the `shopify_app` gem which now implements this responsibility.") |
Co-authored-by: Kevin O'Sullivan <[email protected]>
Co-authored-by: Kevin O'Sullivan <[email protected]>
raise Errors::SessionStorageError, | ||
"Session could not be saved. Please check your session storage implementation." | ||
end | ||
Context.session_storage&.store_session(session) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably an edge case, but should we be retaining the previous behaviour of raising if store_session
returns nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new normal is for Context.session_storage
to be nil as it is deprecated. It's my hope that this will be nil :)
lib/shopify_api/context.rb
Outdated
if @session_storage | ||
::ShopifyAPI::Context.logger.warn("SessionStorage has been deprecated. " \ | ||
"The ShopifyAPI will no longer have responsibility for session persistence. " \ | ||
"Consider using the `shopify_app` gem which now implements this responsibility.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we point to any particular docs here?
def validate_session_storage_for_deprecated_utils | ||
unless Context.session_storage | ||
raise ShopifyAPI::Errors::SessionStorageError, | ||
"session_storage is required in ShopifyAPI::Context when using deprecated Session utility methods." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"session_storage is required in ShopifyAPI::Context when using deprecated Session utility methods." | |
"session_storage is required in ShopifyAPI::Context when using deprecated Session utility methods." |
If these session utility methods are deprecated, what's the recommended replacement? Presumably something in shopify_app
? Should we point them towards that or does that create too much of a link between shopify-api-ruby
and shopify_app
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this particular error will be super hard to reach. This error was put in place mainly because the sorbet one wasn't pretty. I think the upgrade logs we have in the Context.setup
call should help give actionable steps on upgrade path.
Co-authored-by: Kevin O'Sullivan <[email protected]>
Co-authored-by: Kevin O'Sullivan <[email protected]>
…y-api-ruby into response_in_error_object * 'response_in_error_object' of github.com:kaarelss/shopify-api-ruby: Added assertion that response is present in MaxHttpRetriesExceededError Added sorbet assertion Removed extra empty line ShopifyAPI::Clients::HttpResponse as argument for ShopifyAPI::Errors::HttpResponseError because code can be obtained from response as well as headers for custom retry logic Remove mentions of private apps (Shopify#1062) Fix ActiveSupport inflector dependency (Shopify#1063) Move Session Storage to `shopify_app` (Shopify#1055) Remove session argument from REST examples (Shopify#1064) Constrain Zeitwerk to 2.6.5 (Shopify#1059) Clarify statement about packages (Shopify#1057)
Configuring the API with session_storage is now deprecated. Shopify#1055
Configuring the API with session_storage is now deprecated. Shopify/shopify-api-ruby#1055
Configuring the API with session_storage is now deprecated. Shopify/shopify-api-ruby#1055
Description
We would like to remove persistence responsibilities from this API library. Ideally, this API would just deal with API sessions and pass storing, loading, and deleting sessions responsibilities to Shopify App or some other middleware that has persistence.
This change makes
config.session_storage
optional and only makesstore_session
calls if the storage library is provided.TODO
SessionUtils
store_session
How has this been tested?
Checklist: