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

feat: add support to GTFS-RT auth header #59

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

Altonhe
Copy link
Member

@Altonhe Altonhe commented Mar 13, 2024

Support for authentication headers in GTFS-RT feeds has been added, you can test it with

version: "3"

services:
  oba_bundler:
    build: ./bundler
    volumes:
      - ./bundle:/bundle
    environment:
      - GTFS_URL=https://opendata.burlington.ca/gtfs-rt/GTFS_Data.zip

  oba_database:
    image: mysql:8.3
    container_name: oba_database
    environment:
      MYSQL_ROOT_PASSWORD: Ins3cure!
      MYSQL_DATABASE: oba_database
      MYSQL_USER: oba_user
      MYSQL_PASSWORD: oba_password
    ports:
      - "3306:3306"
    volumes:
      - type: volume
        source: mysql-data
        target: /var/lib/mysql
    restart: always

  oba_app:
    container_name: oba_app
    depends_on:
      - oba_database
    build:
      context: ./oba
      # For test only, remove in production
      args:
        - TEST_API_KEY=test
        - VEHICLE_POSITIONS_URL=https://opendata.burlington.ca/gtfs-rt/GTFS_VehiclePositions.pb
        - TRIP_UPDATES_URL=https://opendata.burlington.ca/gtfs-rt/GTFS_TripUpdates.pb
        - ALERTS_URL=https://opendata.burlington.ca/gtfs-rt/GTFS_ServiceAlerts.pb
        - REFRESH_INTERVAL=30
        - AGENCY_ID=Burlington
        - FEED_API_KEY=x-api-key
        - FEED_API_VALUE=1234567890abcdef
    environment:
      - JDBC_URL=jdbc:mysql://oba_database:3306/oba_database
      - JDBC_USER=oba_user
      - JDBC_PASSWORD=oba_password
    volumes:
      # Share the host's `bundle` directory
      # with the filesystem of the OBA service.
      - ./bundle:/bundle
    ports:
      # Access the webapp on your host machine at a path like
      # http://localhost:8080/onebusaway-api-webapp/api/where/agency/${YOUR_AGENCY}.json?key=TEST
      - "8080:8080"
    # restart: always

volumes:
  mysql-data:

Results:

$ cat /usr/local/tomcat/webapps/onebusaway-transit-data-federation-webapp/WEB-INF/classes/data-sources.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
   <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
   <property name="url" value="${JDBC_URL}"/>
   <property name="username" value="${JDBC_USER}"/>
   <property name="password" value="${JDBC_PASSWORD}"/>
 </bean>
 <bean class="org.onebusaway.container.spring.SystemPropertyOverrideConfigurer">
   <property name="order" value="-2"/>
   <property name="properties">
     <props>
       <prop key="bundleStoreRoot">/bundle</prop>
     </props>
   </property>
 </bean>
 <bean id="httpServiceClient" class="org.onebusaway.transit_data_federation.util.HttpServiceClientImpl">
   <constructor-arg type="java.lang.String" value="localhost"/>
   <constructor-arg type="java.lang.Integer" value="8080"/>
   <constructor-arg type="java.lang.String" value="/onebusaway-admin-webapp/api/"/>
 </bean>
 <!--    GTFS-RT related beans, automatically generated by the `bootstrap.sh`-->
 <bean id="gtfsRT" class="org.onebusaway.transit_data_federation.impl.realtime.gtfs_realtime.GtfsRealtimeSource">
   <property name="tripUpdatesUrl" value="https://opendata.burlington.ca/gtfs-rt/GTFS_TripUpdates.pb"/>
   <property name="vehiclePositionsUrl" value="https://opendata.burlington.ca/gtfs-rt/GTFS_VehiclePositions.pb"/>
   <property name="alertsUrl" value="https://opendata.burlington.ca/gtfs-rt/GTFS_ServiceAlerts.pb"/>
   <property name="refreshInterval" value="30"/>
   <property name="agencyId" value="Burlington"/>
   <property name="headersMap">
     <map>
       <entry key="x-api-key" value="1234567890abcdef"/>
     </map>
   </property>
 </bean>
 <bean id="bundleManagementService" class="org.onebusaway.transit_data_federation.impl.bundle.BundleManagementServiceImpl">
   <property name="bundleStoreRoot" value="/bundle"/>
   <property name="standaloneMode" value="true"/>
 </bean>
</beans>

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

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

looks great! So that's how you make it work with xmlstarlet. I swear I was close but just could not make it work right. thanks for bringing this over the finish line! 🎉

@aaronbrethorst aaronbrethorst merged commit 6245853 into OneBusAway:main Mar 13, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants