Skip to content

Commit 7e3ac9b

Browse files
committed
Initial commit
Signed-off-by: rustyclock <[email protected]>
0 parents  commit 7e3ac9b

File tree

6 files changed

+1352
-0
lines changed

6 files changed

+1352
-0
lines changed

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# go-openconnect-sso
2+
3+
A tool for getting login details through Two Factor Authentication for the openconnect clients. This tool only generates a config file with the `cookie`, `servercert` and `host` details which can be used to connect to the OpenConnect VPN server.
4+
5+
### Usage
6+
7+
```shell
8+
go get -u github.com/rustycl0ck/go-openconnect-sso
9+
go-openconnect-sso --server='https://vpn.server.myorg.com' --config ~/my-vpn-cookie/cookie.txt
10+
```
11+
12+
The generate opneconnect config file:
13+
```
14+
$ cat ~/my-vpn-cookie/cookie.txt
15+
cookie=1234567890ABCDEF123
16+
servercert=4567890DEFABC321
17+
# host=https://vpn-cluster-2.server.myorg.com/
18+
```
19+
20+
After the file is successfully generated, you can run the following to connect to the VPN server:
21+
```
22+
openconnect <any-additional-params> --verbose --config ~/my-vpn-cookie/cookie.txt https://vpn-cluster-2.server.myorg.com
23+
```
24+
25+
---
26+
**Credits:** This tool has been inspired by (and ported to go from) https://github.com/vlaci/openconnect-sso
27+

config/config.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package config
2+
3+
import "encoding/xml"
4+
5+
/*******************************************************
6+
Initialization XML Response
7+
**********************************************
8+
<?xml version="1.0" encoding="UTF-8"?>
9+
<config-auth some="attr">
10+
<opaque another="attr">
11+
<tunnel-group>Profile_Name</tunnel-group>
12+
<auth-method>single-sign-on-v2</auth-method>
13+
<config-hash>1234567890123</config-hash>
14+
</opaque>
15+
<auth id="main">
16+
<title>Login</title>
17+
<message>Some useful message for the user to inform about next step for login</message>
18+
<banner></banner>
19+
<sso-v2-login>https://vpn.server.myorg.com/path/to/login/page</sso-v2-login>
20+
<sso-v2-login-final>https://vpn.server.myorg.com/login/successful/page</sso-v2-login-final>
21+
<sso-v2-token-cookie-name>someCookieNameWhichContainsToken</sso-v2-token-cookie-name>
22+
<sso-v2-error-cookie-name>someCookieNameWhichContainsError</sso-v2-error-cookie-name>
23+
<form>
24+
<input type="sso" name="sso-token"></input>
25+
</form>
26+
</auth>
27+
</config-auth>"
28+
*******************************************************/
29+
type InitializationResponse struct {
30+
XMLName xml.Name `xml:"config-auth"`
31+
LoginURL string `xml:"auth>sso-v2-login"`
32+
LoginFinalURL string `xml:"auth>sso-v2-login-final"`
33+
TokenCookieName string `xml:"auth>sso-v2-token-cookie-name"`
34+
Opaque struct {
35+
Value string `xml:",innerxml"`
36+
} `xml:"opaque"`
37+
}
38+
39+
type FinalizationResponse struct {
40+
XMLName xml.Name `xml:"config-auth"`
41+
Cookie string `xml:"session-token"`
42+
Fingerprint string `xml:"config>vpn-base-config>server-cert-hash"`
43+
}
44+
45+
/*******************************************************
46+
Finalization XML Response
47+
**********************************************
48+
<?xml version="1.0" encoding="UTF-8"?>
49+
<config-auth client="vpn" type="complete" aggregate-auth-version="2">
50+
<session-id>2345678901234</session-id>
51+
<session-token>somelongrandomtokenhere</session-token>
52+
<auth id="success">
53+
<banner>Some useful pop up message after successful login</banner>
54+
</auth>
55+
<config attr1="val1">
56+
<vpn-base-config>
57+
<server-cert-hash>0123456789ABCDEF0123</server-cert-hash>
58+
</vpn-base-config>
59+
</config>
60+
</config-auth>
61+
*******************************************************/

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/rustycl0ck/go-openconnect-sso
2+
3+
go 1.16
4+
5+
require (
6+
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 // indirect
7+
github.com/go-kit/kit v0.10.0
8+
github.com/mxschmitt/playwright-go v0.1100.1-0.20210430103100-de638a4c485a
9+
gopkg.in/alecthomas/kingpin.v2 v2.2.6
10+
)

0 commit comments

Comments
 (0)