Skip to content

Cleanup support for AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE#43

Merged
vlovgr merged 6 commits intomainfrom
token-file-cleanup
Aug 18, 2025
Merged

Cleanup support for AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE#43
vlovgr merged 6 commits intomainfrom
token-file-cleanup

Conversation

@vlovgr
Copy link
Copy Markdown
Member

@vlovgr vlovgr commented Aug 16, 2025

Some additional minor cleanup following #42.

.through(utf8.decode)
.compile
.string
.adaptError { case _: NoSuchFileException => MissingCredentials() }
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We do not want to mask errors reading the file if one has been specified. Instead, we surface them to the one requesting credentials, so they can observe the cause.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

} yield Some(Header.Raw(ci"Authorization", s.trim))
case None => none[Header.Raw].pure[F]
}
.recover { case _ => none[Header.Raw] }
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Similar to above, we do not want to mask errors here.

authorizationTokenFile <- ContainerAuthorizationTokenFile[F].read
.flatMap(_.traverse(readContainerAuthorizationTokenFile))
authorizationToken = ContainerAuthorizationToken[F].read
authorization <- authorizationTokenFile.map(_.some.pure).getOrElse(authorizationToken)
Copy link
Copy Markdown
Member Author

@vlovgr vlovgr Aug 16, 2025

Choose a reason for hiding this comment

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

According to the documentation, the authorization token file takes precedence.

Note: This setting is an alternative to AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE and will only be used if AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE is not set.

Reading AWS_CONTAINER_AUTHORIZATION_TOKEN now only happens if a file has not been specified.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, cool!

.flatMap(_.traverse(readContainerAuthorizationTokenFile))
.map(_.map(_.some.pure))
authorizationToken = ContainerAuthorizationToken[F].read
authorization <- authorizationTokenFile.getOrElse(authorizationToken)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, so we want to prioritize file over header?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, answer here.

Copy link
Copy Markdown
Contributor

@jesperoman jesperoman left a comment

Choose a reason for hiding this comment

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

Only a curious question!
👍

@vlovgr vlovgr merged commit 58f7be8 into main Aug 18, 2025
13 checks passed
@vlovgr vlovgr deleted the token-file-cleanup branch August 18, 2025 07:20
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