Repository navigation
Show the Google Calendar subscribe URL from a public base #469
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
Changes from all commits
97850da
55ad53f
de0aafb
533ec7f
98e5744
a62a7b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,6 @@ | |
| import org.phoenixctms.ctsms.vo.*; | ||
| import org.phoenixctms.ctsms.web.model.ApplicationScopeBean; | ||
| import org.phoenixctms.ctsms.web.model.SessionScopeBean; | ||
| import org.phoenixctms.ctsms.web.jersey.resource.trial.DutyRosterTurnResource; | ||
| import org.phoenixctms.ctsms.web.util.Settings.Bundle; | ||
| import org.primefaces.context.RequestContext; | ||
| import org.primefaces.model.DefaultStreamedContent; | ||
|
|
@@ -4314,22 +4313,31 @@ public static StaffOutVO getUserIdentity() { | |
| return null; | ||
| } | ||
|
|
||
| public static boolean isDutyRosterIcsRailEnabled() { | ||
| return !CommonUtil.isEmptyString(getDutyRosterGoogleCalendarIcsBaseUrl()); | ||
| } | ||
|
|
||
| public static boolean isShowDutyRosterGoogleCalendarUrl() { | ||
| return Settings.getBoolean(SettingCodes.DUTY_ROSTER_SCHEDULE_SHOW_GOOGLE_CALENDAR_URL, Bundle.SETTINGS, DefaultSettings.DUTY_ROSTER_SCHEDULE_SHOW_GOOGLE_CALENDAR_URL) | ||
| && getUserIdentity() != null; | ||
| return getUserIdentity() != null && isDutyRosterIcsRailEnabled(); | ||
| } | ||
|
|
||
| public static String getDutyRosterGoogleCalendarIcsUrl() { | ||
| String jwt = issueDutyRosterIcsJwt(); | ||
| if (CommonUtil.isEmptyString(jwt)) { | ||
| String baseUrl = getDutyRosterGoogleCalendarIcsBaseUrl(); | ||
| if (CommonUtil.isEmptyString(jwt) || CommonUtil.isEmptyString(baseUrl)) { | ||
| return ""; | ||
| } | ||
| StringBuilder sb = new StringBuilder(getHttpBaseUrl()); | ||
| sb.append("/").append(REST_API_PATH).append(DutyRosterTurnResource.ICS_PATH); | ||
| sb.append("?").append(JWT_QUERY_PARAM).append("=").append(urlEncodeUtf8(jwt)); | ||
| StringBuilder sb = new StringBuilder(baseUrl); | ||
| sb.append(baseUrl.indexOf('?') >= 0 ? '&' : '?'); | ||
| sb.append(JWT_QUERY_PARAM).append("=").append(urlEncodeUtf8(jwt)); | ||
| return sb.toString(); | ||
| } | ||
|
|
||
| private static String getDutyRosterGoogleCalendarIcsBaseUrl() { | ||
| String baseUrl = Settings.getString(SettingCodes.DUTY_ROSTER_GOOGLE_CALENDAR_ICS_BASE_URL, Bundle.SETTINGS, DefaultSettings.DUTY_ROSTER_GOOGLE_CALENDAR_ICS_BASE_URL); | ||
| return baseUrl == null ? "" : baseUrl.trim(); | ||
|
Comment on lines
+4337
to
+4338
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Require HTTPS for the public ICS base URL. If an operator configures an 🤖 Prompt for AI AgentsSource: Learnings |
||
| } | ||
|
|
||
| private static String issueDutyRosterIcsJwt() { | ||
| AuthenticationVO sessionAuth = getAuthentication(); | ||
| if (sessionAuth == null) { | ||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep the assignee identifiable in cross-staff feeds.
When an authorized request selects another
staff_id,calendarName(auth)names the viewer, but the event summary no longer namesturn.getStaff(). The description and category do not supply the assignee either. A subscriber cannot tell whose duty a returned event represents. Preserve the staff name for turns assigned to someone other than the viewer, or restrict this feed to the viewer’s turns. (raw.githubusercontent.com)🤖 Prompt for AI Agents