Skip to content

Conversation

@omarzl
Copy link

@omarzl omarzl commented Jan 10, 2023

Solves issue #141
Inspired by this fork commit: tahirmt@2da7761

fastlane spaceauth generates a YML session string so we can parse it directly and inject those cookies into the session's cookies storage.

I kept the FASTLANE_SESSION env var name to have direct support with fastlane.

Steps

You will now be able to download Xcode in CI environments by first running locally:

fastlane spaceauth -u username@email.com

And then in your CI scripts you can export the variable and run xcodes, it won't prompt for username/password/2fa:

export  FASTLANE_SESSION='---\n-.......'
xcodes download 14.0

References:
https://github.com/fastlane/fastlane/blob/master/spaceship/lib/spaceship/client.rb#L280
https://github.com/sparklemotion/http-cookie/blob/master/lib/http/cookie_jar/yaml_saver.rb#L19

@omarzl omarzl requested a review from a team as a code owner January 10, 2023 02:26

func load(in storage: HTTPCookieStorage?) {
do {
guard let storage, var sessionVar = Current.shell.env(fastlaneSession) else { return }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's also valuable to automatically load the cookie if it is present in the filesystem. fastlane stores it in the file ~/.fastlane/spaceship/email@domain.com/cookie.

import Foundation
import Yams

struct FastlaneCookieLoader {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind adding some tests for this?

@tahirmt
Copy link
Contributor

tahirmt commented Jan 10, 2023

This will close #248

@tahirmt
Copy link
Contributor

tahirmt commented Jan 10, 2023

Also possible duplicate of #257

@omarzl
Copy link
Author

omarzl commented Jan 10, 2023

Also possible duplicate of #257

Oh there was another pr already parsing the cookie using Yams, I think we should prefer #257 instead of mine since it has a more complete solution

@tahirmt
Copy link
Contributor

tahirmt commented Feb 7, 2023

@omarzl can you close this PR if it isn't needed?

@omarzl
Copy link
Author

omarzl commented Feb 7, 2023

Sure!

@omarzl omarzl closed this Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants