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

Initial declaration of OAuth and OIDC plugin and validator with unimp… #1276

Open
wants to merge 1 commit into
base: activemq-6.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions activemq-broker/README_OAUTH_OIDC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# OAuth and OIDC Implementation for ActiveMQ
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it makes sense to add a specific README here. Better to add in the doc section.

Also the ASF header is missing.


## Overview
This document outlines the plan to implement OAuth and OIDC authentication for ActiveMQ. The implementation will be done in a maxiumum of four stages:
1. Initial declaration of changes and setup.
2. Implementation of OAuth and OIDC methods.
3. Adding unit and integration tests.
4. Implementing logging for OAuth and OIDC operations.

## Plugin configuration in the activemq.xml file

<plugins>
<bean id="oidcAuthenticationPlugin" class="org.apache.activemq.security.OIDCAuthenticationPlugin">
<property name="clientId" value="YOUR_COMPANY_CLIENT_ID"/>
<property name="clientSecret" value="YOUR_COMPANY_CLIENT_SECRET"/>
<property name="oidcServerUrl" value="https://oidc-server.com"/>
<property name="oidcIssuer" value="https://oidc-issuer.com"/>
</bean>
</plugins>
9 changes: 9 additions & 0 deletions activemq-broker/README_OAUTH_OIDC.md.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OAuth and OIDC Implementation for ActiveMQ
Copy link
Member

Choose a reason for hiding this comment

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

bak file should not be part of the PR. Please remove this one.


## Overview
This document outlines the plan to implement OAuth and OIDC authentication for ActiveMQ. The implementation will be done in a maxiumum of four stages:
1. Initial declaration of changes and setup.
2. Implementation of OAuth and OIDC methods.
3. Adding unit and integration tests.
4. Implementing logging for OAuth and OIDC operations.

20 changes: 19 additions & 1 deletion activemq-broker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>



<!-- =============================== -->
<!-- Optional Dependencies -->
<!-- =============================== -->
Expand All @@ -67,6 +68,23 @@
<optional>true</optional>
</dependency>

<!-- =============================== -->
<!-- oAuth and OIDC Dependencies -->
<!-- Nimbus JOSE + JWT dependencies -->
<!-- =============================== -->

<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
<version>9.15</version>
Copy link
Member

Choose a reason for hiding this comment

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

  1. The version should be managed by dependencyManagement in the root pom.
  2. These dependencies can be optional I guess.

</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
<version>9.40</version>
</dependency>


<!-- =============================== -->
<!-- Testing Dependencies -->
<!-- =============================== -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.apache.activemq.security;
Copy link
Member

Choose a reason for hiding this comment

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

ASF header is missing here.


public class OAuthValidator {
private String clientId;
private String clientSecret;
private String oidcServerUrl;
private String oidcIssuer;

public OAuthValidator(String clientId, String clientSecret, String oidcServerUrl, String oidcIssuer) {
this.clientId = clientId;
this.clientSecret = clientSecret;
this.oidcServerUrl = oidcServerUrl;
this.oidcIssuer = oidcIssuer;
}

public void initialize() {
throw new UnsupportedOperationException("Method not implemented yet");
}

public boolean validateToken(String token) {
throw new UnsupportedOperationException("Method not implemented yet");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.apache.activemq.security;
Copy link
Member

Choose a reason for hiding this comment

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

ASF header is missing here.


import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerPlugin;
import org.apache.activemq.broker.BrokerPluginSupport;
import org.apache.activemq.command.ConnectionInfo;
import org.apache.activemq.security.OIDCSecurityContext;

public class OIDCAuthenticationPlugin implements BrokerPlugin {
private String clientId;
private String clientSecret;
private String oidcServerUrl;
private String oidcIssuer;

@Override
public Broker installPlugin(Broker broker) {
return new OIDCBroker(broker);
}

private class OIDCBroker extends BrokerPluginSupport {
private final Broker next;

public OIDCBroker(Broker next) {
this.next = next;
}

@Override
public void addConnection(org.apache.activemq.broker.ConnectionContext context, ConnectionInfo info) throws Exception {
throw new UnsupportedOperationException("Method not implemented yet");
}

private OIDCSecurityContext authenticate(String token) {
throw new UnsupportedOperationException("Method not implemented yet");
}
}

public String getClientId() {
return clientId;
}

public void setClientId(String clientId) {
this.clientId = clientId;
}

public String getClientSecret() {
return clientSecret;
}

public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}

public String getOidcServerUrl() {
return oidcServerUrl;
}

public void setOidcServerUrl(String oidcServerUrl) {
this.oidcServerUrl = oidcServerUrl;
}

public String getOidcIssuer() {
return oidcIssuer;
}

public void setOidcIssuer(String oidcIssuer) {
this.oidcIssuer = oidcIssuer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.apache.activemq.security;
Copy link
Member

Choose a reason for hiding this comment

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

ASF header is missing here.


import java.security.Principal;
import java.util.Set;

public class OIDCSecurityContext extends SecurityContext {
private final Set<Principal> principals;

public OIDCSecurityContext(String userName, Set<Principal> principals) {
super(userName);
this.principals = principals;
}

@Override
public Set<Principal> getPrincipals() {
return principals;
}
}
3 changes: 3 additions & 0 deletions activemq-web-console/src/main/webapp/WEB-INF/activemq.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<transportConnectors>
<transportConnector name="openwire" uri="tcp://localhost:61616" />
<transportConnector name="stomp" uri="stomp://localhost:61613" />
<!-- Add Jetty Transport Connector for Web Console -->
Copy link
Member

Choose a reason for hiding this comment

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

That's not correct: the jetty transport is not for the webconsole. Jetty transport is for http transport connect.
The WebConsole is managed outside of the broker by inclusion of jetty.xml.

<transportConnector name="jetty" uri="http://localhost:8161"/>

</transportConnectors>

</broker>
Expand Down