Skip to content
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

Add Auth support for websocket clients #820

Closed
4 tasks done
Tracked by #577
Bhashinee opened this issue Jan 8, 2021 · 0 comments · Fixed by ballerina-platform/module-ballerina-websocket#66
Closed
4 tasks done
Tracked by #577
Assignees
Labels

Comments

@Bhashinee
Copy link
Member

Bhashinee commented Jan 8, 2021

This task has the following auth types to be completed.
This is implemented in a declarative manner.

  • Bearer token
webscket:Client wsClient = check new("ws://localhost:21324/bearerToken/", config = {
            auth: {
              token: "JlbmMiOiJBMTI4Q0JDLUhTMjU2Inikn"
            }
        });
  • Basic auth
websocket:Client wsClient = check new("ws://localhost:21318/basicAuth/", config = {
            auth: {
                username: "alice2",
                password: "1234"
            }
        });
  • JWT
websocket:Client wsClient = check new("ws://localhost:21320/jwtSyncAuthService/", config = {
            auth: {
                    username: "wso2",
                    issuer: "ballerina",
                    audience: ["ballerina", "ballerina.org", "ballerina.io"],
                    keyId: "5a0b754-895f-4279-8843-b745e11a57e9",
                    customClaims: { "scp": "hello" },
                    expTime: 3600,
                    signatureConfig: {
                        config: {
                            keyAlias: "ballerina",
                            keyPassword: "ballerina",
                            keyStore: {
                                path: "tests/certsAndKeys/ballerinaKeystore.p12",
                                password: "ballerina"
                            }
                        }
                    }
                }
            });
  • OAuth2
websocket:OAuth2DirectTokenConfig config = {
    refreshUrl: "https://localhost:9401/oauth2/token/refresh",
    refreshToken: "XlfBs91yquexJqDaKEMzVg==",
    clientId: "3MVG9YDQS5WtC11paU2WcQjBB3L5w4gz52uriT8ksZ3nUVjKvrfQMrU4uvZohTftxStwNEW4cfStBEGRxRL68",
    clientSecret: "9205371918321623741",
    scopes: ["token-scope1", "token-scope2"],
    clientConfig: {
        secureSocket: {
           cert: {
               path: "tests/certsAndKeys/ballerinaTruststore.p12",
               password: "ballerina"
           }
        }
    }
};

websocket:Client wsClient = check new("ws://localhost:21325/oauthService/", config = {auth: config});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants