-
Notifications
You must be signed in to change notification settings - Fork 131
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
Upgrading crewjam/saml from v0.3.0 to v0.4.5 #169
Conversation
I’ll gladly test but need a walk through on how to put this all together. I use the docker image. |
@metalcated I also use docker for convenience. This would be done so:
version: "3.3"
services:
subspace:
image: subspace-local
build: .
# image: subspacecommunity/subspace
container_name: subspace
volumes:
- ./subspace-data:/data
# - ./subspace-log:/etc/service/subspace/log
restart: always
environment:
- SUBSPACE_HTTP_HOST=192.168.0.4
- SUBSPACE_LETSENCRYPT=false
- SUBSPACE_HTTP_INSECURE=true
- SUBSPACE_HTTP_ADDR=":80"
- SUBSPACE_NAMESERVERS=1.1.1.1,8.8.8.8
- SUBSPACE_LISTENPORT=51820
- SUBSPACE_IPV4_POOL=10.99.97.0/24
- SUBSPACE_IPV6_POOL=fd00::10:97:0/64
- SUBSPACE_IPV6_NAT_ENABLED=1
cap_add:
- NET_ADMIN
network_mode: "host"
Tests I can think of:
Edit docker exec -it subspace bash
# then inside the container
tail -f /etc/service/subspace/log/main/current |
cmd/subspace/web.go
Outdated
@@ -190,10 +190,17 @@ func WebHandler(h func(*Web), section string) httprouter.Handle { | |||
|
|||
// Needs a new session. | |||
if samlSP != nil { | |||
if token := samlSP.GetAuthorizationToken(r); token != nil { | |||
r = r.WithContext(samlsp.WithToken(r.Context(), token)) | |||
session, _ := samlSP.Session.GetSession(r) |
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.
Maybe it's better to handle this error too? We can log it if it's difficult to integrate it into the current user flow.
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.
as singin will be required at the end of the middleware flow, we could just log the error for future reference and continue, because session will be nil
anyways. Or do you think it would be better to explicitly redirect to /signin
?
Lines 237 to 238 in e3fc811
logger.Warnf("auth: sign in required") | |
web.Redirect("/signin") |
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.
added logging to the error, however, now every time we start the container it logs an error. I will change it to debug instead of error
Kudos, SonarCloud Quality Gate passed! |
@metalcated I just tested with Okta, using a newly created free account and I successfully logged into subspace. Here is what I did: Note: you have to set name ID and application username to use the email address. Subspace works by validating users by email. Also, change Hope it helps! |
Not sure why it doesn't work for me but consistently get "forbidden". I did
validate the settings and even paste in the new SAML metadata. This was
setup and working for a couple years but just simply is not working. Maybe
AD integration causes it not to work? I will create a whole new account and
try later on.
…On Tue, May 11, 2021 at 6:58 AM Gabriel Chamon Araujo < ***@***.***> wrote:
@metalcated <https://github.com/metalcated> I just tested with Okta,
using a newly created free account and I successfully logged into subspace.
Here is what I did:
- Creating the okta app
[image: image]
<https://user-images.githubusercontent.com/9471861/117804371-14ac2d80-b22e-11eb-9e47-a598c2740a6b.png>
[image: image]
<https://user-images.githubusercontent.com/9471861/117804404-1fff5900-b22e-11eb-8496-c7bc355e3828.png>
[image: image]
<https://user-images.githubusercontent.com/9471861/117804436-28f02a80-b22e-11eb-9682-79d2464cba41.png>
*Note*: you have to set name ID and application username to use the email
address. Subspace works by validating users by email. Also, change
192.168.0.4 to whatever the URL of your instance is. In my case, I also
used http because I am testing inside a private network.
-
download okta metadata
[image: image]
<https://user-images.githubusercontent.com/9471861/117804737-81bfc300-b22e-11eb-9c73-8cc5fc61948b.png>
-
Paste its contents to subspace metadata field
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#169 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKRQCUCFZAPXEU2O4R7QV3TNEEUHANCNFSM44LLGGWA>
.
|
I have little experience with the actual process of federating user login, and less so with Okta. Sorry I cannot be more of help. But a couple of ideas: |
@metalcated one last thing I forgot. You must add users to your Okta SSO app otherwise they wont be allowed to access to application. You do it by adding the users in the |
Fresh app, fresh data directory and same issue. It worked on the
original subspace and still does if I revert back to that image. I was told
previously this was a SAML 2.0 integration issue in the Subspace community
version. Not sure how true that is, that response came from the Slack
channel.
https://gophers.slack.com/archives/C013TP4AT3Q/p1598263068005800
…On Tue, May 11, 2021 at 9:42 AM Gabriel Chamon Araujo < ***@***.***> wrote:
@metalcated <https://github.com/metalcated> one last thing I forgot. You
must add users to your Okta SSO app otherwise they wont be allowed to
access to application. You do it by adding the users in the Assignments
tab in your application:
[image: image]
<https://user-images.githubusercontent.com/9471861/117825191-7d52d480-b245-11eb-96a8-264bf0b825db.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#169 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKRQCQ3VFIDXAFA52QJ5MLTNEX3LANCNFSM44LLGGWA>
.
|
I wonder if this is due to me using an nginx reverse proxy with an SSL cert
outside of the subspace install. I will keep playing around with it and let
you know.
…On Tue, May 11, 2021 at 10:10 AM Mike Gomon ***@***.***> wrote:
Fresh app, fresh data directory and same issue. It worked on the
original subspace and still does if I revert back to that image. I was told
previously this was a SAML 2.0 integration issue in the Subspace community
version. Not sure how true that is, that response came from the Slack
channel.
https://gophers.slack.com/archives/C013TP4AT3Q/p1598263068005800
On Tue, May 11, 2021 at 9:42 AM Gabriel Chamon Araujo <
***@***.***> wrote:
> @metalcated <https://github.com/metalcated> one last thing I forgot. You
> must add users to your Okta SSO app otherwise they wont be allowed to
> access to application. You do it by adding the users in the Assignments
> tab in your application:
>
> [image: image]
> <https://user-images.githubusercontent.com/9471861/117825191-7d52d480-b245-11eb-96a8-264bf0b825db.png>
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#169 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAKRQCQ3VFIDXAFA52QJ5MLTNEX3LANCNFSM44LLGGWA>
> .
>
|
Just deployed in production where I work. Zero problems so far with Azure AD. |
Works fine with Google Workspace. Good job! |
@metalcated did you manage to get this to work? I would like to have this merged. The problem with SAML is that is very hard to integrate in something like a Unit Test, so setting up environments to test changes in a clean space for every PR is a bit hard |
@agonbar I have a terraform module for subspace that works well, but needs documentation. It could serve to create disposable environments for these types of experiments. |
Not yet, I’m going to deploy a new vm in my lab and see if it works.
Letsencrypt is not even working. It’s behind a firewall and port
forwarding. I’m going to use a public ip instead and see what happens.
Thanks
…On Sun, May 16, 2021 at 4:29 PM Adrián González Barbosa < ***@***.***> wrote:
@metalcated <https://github.com/metalcated> did you manage to get this to
work? I would like to have this merged. The problem with SAML is that is
very hard to integrate in something like a Unit Test, so setting up
environments to test changes in a clean space for every PR is a bit hard
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#169 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKRQCSLHXY4JJELX6V24FLTOATLVANCNFSM44LLGGWA>
.
|
We need a common place to discuss changes and what not. I own a Rocket.Chat
server and can create a channel dedicated to subspace (yes I know there is
already one on Slack but no one even talks in there or responds). Let me
know and I will send registration links to whoever is interested.
Thanks.
…On Sun, May 16, 2021 at 7:19 PM Mike Gomon ***@***.***> wrote:
Not yet, I’m going to deploy a new vm in my lab and see if it works.
Letsencrypt is not even working. It’s behind a firewall and port
forwarding. I’m going to use a public ip instead and see what happens.
Thanks
On Sun, May 16, 2021 at 4:29 PM Adrián González Barbosa <
***@***.***> wrote:
> @metalcated <https://github.com/metalcated> did you manage to get this
> to work? I would like to have this merged. The problem with SAML is that is
> very hard to integrate in something like a Unit Test, so setting up
> environments to test changes in a clean space for every PR is a bit hard
>
> —
> You are receiving this because you were mentioned.
>
>
> Reply to this email directly, view it on GitHub
> <#169 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAKRQCSLHXY4JJELX6V24FLTOATLVANCNFSM44LLGGWA>
> .
>
|
@metalcated Lets try that |
I emailed your live.com account with a registration link.
Secondly it's working using the IP but not a public DNS registered
hostname. I am going to keep trying a couple different things. Reverse
Proxy seems to work fine so no issue there.
…On Sun, May 16, 2021 at 9:33 PM Gabriel Chamon Araujo < ***@***.***> wrote:
@metalcated <https://github.com/metalcated> Lets try that
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#169 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKRQCWNJ74PACIBGPWUKXLTOBW7ZANCNFSM44LLGGWA>
.
|
@metalcated I am getting error 1020, Access Denied from cloudflare |
I think my issues are all Cloudflare related. Their SSL enforcement is
overly secure which is a good thing but makes it impossible to manage this.
I am going to use a different domain I own and move the DNS to somewhere
else and test there as well to see if I still experience the problem.
Calling it a night for now but I will respond back once I have something to
report.
This is what I believe to be the reason autocert is not working:
golang/go#37489
…On Sun, May 16, 2021 at 10:21 PM Mike Gomon ***@***.***> wrote:
I emailed your live.com account with a registration link.
Secondly it's working using the IP but not a public DNS registered
hostname. I am going to keep trying a couple different things. Reverse
Proxy seems to work fine so no issue there.
On Sun, May 16, 2021 at 9:33 PM Gabriel Chamon Araujo <
***@***.***> wrote:
> @metalcated <https://github.com/metalcated> Lets try that
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#169 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAKRQCWNJ74PACIBGPWUKXLTOBW7ZANCNFSM44LLGGWA>
> .
>
|
@metalcated do you think there could be anything we could do on our part to support Cloudflare? |
I think we could do something differently to auto generate SSL certificates that do work with Cloudflare. Possibly allow the usage of externally generated certs which can be configured via docker-compose.yml or something to that effect. |
You can try again, I unblocked Brazil. |
I believe this would be a new feature request, with a different issue worth investigating. |
Well, the cloudflare certificates problem can go to another PR, so after some tests, I'm merging this. Thanks to everyone for all the work! |
to:
cc: @subspacecommunity/subspace-maintainers
related to:
resolves: #167
Background
There was a severe vulnerability in crewjam/saml v0.3.0 that allowed bypassing SAML SSO. Updating to v0.4.5 would solve the issue.
The way SAML works in subspace is to basically split the handler procedure encoded in
samlSP.RequreAccount
. This function is supposed to make it easy to use SAML SSO, however it requires the use of purenet/http
. As we usejulienschmidt/httprouter
. We have to handle it ourselves.The way this is done is basically split
samlSP.RequreAccount
in two. The first part is implemented in the two handlersssoHandler
andsamlHandler
.ssoHandler
, in turn handles specifically the authentication flow. Therefore, we must reimplement it usingsamlSP.HandleStartAuthFlow
. The code in it is almost the same as insamlSP.RequreAccount
. The difference is thatsamlSP. ServeHTTP
is reserved forsamlHandler
.The other modification was the refactoring of the procedure that extracts the subject name from the JWT Token. This changed quite drastically in 0.4.x. This version did away with the convenient function
GetAuthorizationToken
. Now we have to extract the session from the conext and use type assertion to cast it toJWTSessionClaims
. Without it, we would be left withsessionWithAttributes.GetAttributes
which in turn only returns the contents ofattrs
of the JWT Token. This cast restores the access to what was previously retrieved withtoken.StandardClaims
. Now we access it withjwtSessionClaim
directly, which is the complete decoded jwt token.DISCLAIMER: I am NOT a security expert and the first contact I ever had with golang was applying this fix. So I welcome everyone to treat this pull request as an invitation for debating, so that we can arrive at an optimal solution.
Changes
Testing