-
Notifications
You must be signed in to change notification settings - Fork 44
Add pekko-http-cors module #208
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
Conversation
LICENSE
Outdated
|
||
pekko-http-cors contains code that was donated by Lomig Mégard to the Apache Software Foundation | ||
via a Software Grant Agreement <https://www.apache.org/licenses/contributor-agreements.html#grants> | ||
See <https://github.com/lomigmegard/pekko-http-cors/issues/33>. |
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.
We don't need this if the code was granted to us
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.
if we include something, it should be in the NOTICE file but I don't think we need to include anything
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.
Better we have a durable record somewhere?
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.
Since the code is granted to us, I don't see how this differs much from a standard PR that we get. And with PRs generally, we do not modify the LICENSE and we insist that all source files are given Apache license headers.
The LICENSE addenda are to point out 3rd party code that has different licenses or that has copyright declarations in those licenses (if the original code was ASL but had a specific copyright in it).
I would favour highlighting the source of the code but I would suggest that we do that in the source files adding something like:
// based on code from pekko-http-cors <https://github.com/lomigmegard/pekko-http-cors> which has been granted
// to the Apache Pekko project - the Software Grant agreement is on record with the Secretary of the ASF
Edited to use pekko-http-cors
based on @lomigmegard 's agreement not to delete that repo (just to archive it)
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.
We could link to https://github.com/lomigmegard/pekko-http-cors but there is a risk that @lomigmegard could delete that repo.
I was thinking of just archiving it, thus any link will still work.
|
||
pekko-http-cors contains code that was donated by Lomig Mégard to the Apache Software Foundation | ||
via a Software Grant Agreement <https://www.apache.org/licenses/contributor-agreements.html#grants> | ||
See <https://github.com/lomigmegard/pekko-http-cors/issues/33>. |
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.
I don't think we need this - StandardLicense should be ok for this module
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 license changes need to be thought through
61af596
to
a989df6
Compare
@justinmclean Is it possible to comment on #208 (review), i.e. do we need to mention in |
a989df6
to
f8e9f46
Compare
Compile failures are due to pekko RC2 being dropped, when @pjfanning creates pekko RC3 this will be resolved. One thing that I noticed is that we need to do modifications to sbt-header, this is because our standard header i.e.
Is not correct for pekko-http-cors since it was not derived from Akka (emphasis on |
RC3 jars area ready - see #209 |
f09de05
to
fd3289e
Compare
I have fixed the issue of sbt-header applying on files that it shouldn't, see the last point in #208 (comment) for more details. |
http-cors/src/main/scala/org/apache/pekko/http/cors/javadsl/CorsDirectives.scala
Outdated
Show resolved
Hide resolved
http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettings.scala
Outdated
Show resolved
Hide resolved
fd3289e
to
71b282e
Compare
Thanks for the PR @mdedetrich. I reviewed it and found only a couple places where some utilities from pekko could be re-used, but it can be done in another commits (or even PRs). Regarding your question for breaking changes, the main point I see are the default values for the configuration. Especially |
It was already reference.conf :) |
@@ -0,0 +1,59 @@ | |||
package org.apache.pekko.http.cors.javadsl.settings |
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.
all source files must have license headers - please use the standard Apache one
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.
I swear I saw it somewhere that headers for original/SGA code was a convention but I might be misremembering. I will fix this after I resolve @lomigmegard review comments.
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 code is granted to us - we can add headers and we need an Apache header
if the original code had headers, we' d have to keep them or get @lomigmegard 's permission to change them
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.
So just to confirm, since the original code has no headers I need to add the standard Apache one?
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.
could you use the full header from https://www.apache.org/legal/src-headers.html ?
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.
I just updated the PR before your comment, I ended up using
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* license agreements; and to You under the Apache License, version 2.0:
*
* https://www.apache.org/licenses/LICENSE-2.0
*/
which is the same as the standard header but without the "derived from Akka" part
I will change it to full license header now.
Thanks, when I was talking about breaking changes I was alluding to binary compatibility and not behavioural. However the point about cors permissions being overly permissive is one that should be noted.
Hmm, I must have gave it the wrong name when copying, my bad! |
71b282e
to
1da238f
Compare
http-cors/src/main/scala/org/apache/pekko/http/cors/javadsl/settings/CorsSettings.scala
Show resolved
Hide resolved
@lomigmegard I addressed all of your comments and sent a re-review but when going through the code I noticed some things. |
I did briefly think about it and I came to similar pros/cons as you did but I opted to put it as a separate module for the following reasons
That being said if you feel strongly that it should go into core then its something that can be explored @pjfanning I have fixed all of the legal/license/header stuff you mentioned before (turns out I entirely forgot that sbt-header will accept source files with standard apache header). Can you re-review it? |
I think we should use the full header from https://www.apache.org/legal/src-headers.html |
I noticed your comment after I pushed PR, fixing it now |
@pjfanning Just pushed with the full Apache license header |
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.
lgtm
@mdedetrich before we release, we probably need to raise an issue at https://issues.apache.org/jira/projects/LEGAL/issues to discuss how to acknowledge this code. Pertinent points are:
My suggestion would be a short mention in our NOTICE file. Something a bit like the BEA mention in https://github.com/apache/poi/blob/trunk/legal/NOTICE The first answer on https://issues.apache.org/jira/browse/LEGAL-150 - I think this gives us the basis to apply the ASL headers that we have already added. |
@pjfanning I just added a mention in the NOTICE file, if the text needs to be updated let me know. |
@mdedetrich I think that NOTICE statement looks good |
Perfect I will leave this PR open till early next week incase @jrudolph @lomigmegard have any further additional comments, then I will merge it. |
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.
LGTM, just a few minor comments.
(I usually use the https://conventionalcomments.org/ notation for my comments)
http-cors/src/main/scala/org/apache/pekko/http/cors/javadsl/CorsDirectives.scala
Outdated
Show resolved
Hide resolved
http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpHeaderRange.scala
Outdated
Show resolved
Hide resolved
http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpHeaderRange.scala
Outdated
Show resolved
Hide resolved
http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpOriginMatcher.scala
Outdated
Show resolved
Hide resolved
http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettings.scala
Outdated
Show resolved
Hide resolved
http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpHeaderRange.scala
Outdated
Show resolved
Hide resolved
Another thing I noticed is that we happen to have public @jrudolph @lomigmegard wdyt? |
Co-Authored-By: Lomig Mégard <[email protected]>
I wouldn't worry about binary compatibility yet - we have no releases to be binary compatible with. I would favour using case classes over classes with custom toString/hashCode/equals/etc. |
Its not about what people are currently using, its about any potential future changes. If you have a final case class MyCaseClass(string: String) And you add a field some point in the future, i.e. final case class MyCaseClass(string: String, int: Int) This will break binary compatibility for This is a known problem and there is a massive thread on Scala contributors about it https://contributors.scala-lang.org/t/pre-sip-structural-data-structures-that-can-evolve-in-a-binary-compatible-way/5684 |
I agree about to be careful on the binary compatibility. However in the case of this library, all the occurrences of final case class CorsRejection(cause: CorsRejection.Cause)
|
Ah yes, I completely forgot that in this case pekko/akka-http uses
Since its
Yes, I completely forgot about this technique and there are definitely places where this needs to be done, have a look at https://github.com/apache/incubator-pekko-connectors/blob/main/s3/src/main/scala/org/apache/pekko/stream/connectors/s3/model.scala ! |
@lomigmegard FYI on this topic of |
Im going to go ahead and merge this now. Many thanks @lomigmegard for your help on the review! |
This PR adds pekko-http-cors support to pekko-http via the merge of akka-http-cors/pekko-http-cors (see lomigmegard/pekko-http-cors#33). Notable points
LEGAL
file and to theMETA-INF
jar indicating that the code was granted to ASF via SGA)org.apache.pekko.http.cors.javadsl.settings.CorsSettings.getMaxAge
was changed fromOptional[Long]
toOptionalLong
since this is consistent within the rest of the Akka/Pekko ecosystem (and is also idiomatic for Java use)get*
public Java API methods inCorsSettings
This was an accident on my partapplication.conf
was renamed toreference.conf
(usingapplication.conf
was likely an oversight, it should be used for actual applications where asreference.conf
should be used for libraries).pekko-http-cors
topekko.http.cors
to be consistent with the rest of the Pekko Http.docs/src/main/paradox/common/cors.md
) which is largely inspired by https://github.com/lomigmegard/pekko-http-cors/blob/master/README.md however I have made some liberties in changes so its more consistent with Pekko documentation, specificallyreference.conf
and has been added todocs/src/main/paradox/configuration.md
.@@snip
rather than just referencing it.#### allowGenericHttpRequests / getAllowGenericHttpRequests
should also be removed because they are duplicated in the scala docs and is also not typical with Pekko Http documentation (let me know what you think on this point).pekko-http-cors
project. Note that only sources have been ignored, resources (such asreference.conf
) still get checked mainly for the# SPDX-License-Identifier: Apache-2.0
header. This is on the presumption that headers are not recommended/necessary for non derived/SGA approved Apache source code.@lomigmegard Pinging you so you can also review the PR and let me know your thoughts. The most critical thing here is any changes that you think would need to be done now otherwise they would break users in the future (i.e. the
Optional[Long]
toOptionalLong
is an example of this) which you weren't able to do in akka-http-cors due to breaking downstream users.