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

Spring Security Bonus Module #54

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

brclark
Copy link

@brclark brclark commented Dec 7, 2023

Contains curriculum for Java Authentication Bonus Module. This module covers a multi-step process to use Spring Security framework and design some Coding Events features that would make use of multiple user roles and privileges.

The lessons are being added to Chapter 19 Authentication/Next Steps/Bonus Module.

The sequence of lessons are:

  1. User Data: Add relationships to User and resources like Event to allow users to own their data
  2. Add Services: Make use of Spring @Service classes to handle logic between @Controller and @Repository, which also makes more use of DTO objects for data translation
  3. Add User Roles & Privileges: Create models for roles and privileges that can be associated with users
  4. Spring Security Features: Fully Implement Authentication and Authorization in Spring Security 6, to handle request filters and session management
  5. Role Based Access: Limit access to Coding Events based on the assigned User role, such as base ROLE_USER, event organizer ROLE_ORGANIZER, and admin ROLE_ADMIN.

The associated code is in the following project:
https://github.com/brclark/CodingEventsJava/tree/user-data

Added new curriculum text for User Owned Data to the Authentication
chapter. First draft so it needs to be edited.

This section describes how users can own the data they create in
Coding Events.

TODO:
 - Create tutorial video
 - Edit this section
- Add content for DTOs and Services
- TODO:
    - Add video content
    - Complete rest of code description
The PasswordEncoder is no longer stored inside the User model as
a static instance. It has been moved to a configuration class and
is a managed bean of the Spring framework.
- Added fixes for UserService description
- Add descriptions for EventService and EventCategoryService
- Add description to refactor controllers to use services
Description was missing explanation of `save` and `validateUser` methods.
Added explanations and code snippets.
Add text based content for how to add roles and privileges to Coding Events
and associate them to users. This content does not include any changes to
functionality.
Added text description for how to preload data in to the database
for user roles and privileges.
Create a bonus module within "Next Steps" to house the curriculum for
user roles and privileges and spring security. This is within the
Authentication chapter
Add description for initial implementation of `SecurityService` to
User Roles & Privileges curriculum.
Adds content for Spring Security bonus module:
- Instructions on using spring security framework for user authentication
- Instructions for spring security authorization framework using
security context filters
@brclark brclark self-assigned this Dec 7, 2023
Copy link

netlify bot commented Dec 7, 2023

Deploy Preview for java-web-dev-curriculum ready!

Name Link
🔨 Latest commit 01748af
🔍 Latest deploy log https://app.netlify.com/sites/java-web-dev-curriculum/deploys/65b1746a1d6ed3000836b8d9
😎 Deploy Preview https://deploy-preview-54--java-web-dev-curriculum.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brclark
Copy link
Author

brclark commented Dec 7, 2023

@brclark brclark marked this pull request as draft December 7, 2023 17:09
Create user attendance relationship and UI CRUD
Add `PreAuthorize` annotation to controllers to restrict access
based on role
Update navigation to reflect the current user's role
@brclark brclark force-pushed the spring-security-dev branch from 6fcd908 to 3ff0e31 Compare December 11, 2023 19:00
Fix mermaid issues and clean up grammar/spelling
@brclark brclark marked this pull request as ready for review December 12, 2023 16:22
@brclark brclark marked this pull request as draft December 12, 2023 16:22
@brclark brclark marked this pull request as ready for review December 12, 2023 16:46
Copy link
Author

@brclark brclark left a comment

Choose a reason for hiding this comment

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

Review of User Owned Data, and Add Service DTOs instructions

content/authentication/reading/add-service-dto/_index.md Outdated Show resolved Hide resolved
content/authentication/reading/add-service-dto/_index.md Outdated Show resolved Hide resolved
content/authentication/reading/add-service-dto/_index.md Outdated Show resolved Hide resolved
content/authentication/reading/add-service-dto/_index.md Outdated Show resolved Hide resolved
content/authentication/reading/add-service-dto/_index.md Outdated Show resolved Hide resolved
content/authentication/reading/add-service-dto/_index.md Outdated Show resolved Hide resolved
content/authentication/reading/add-service-dto/_index.md Outdated Show resolved Hide resolved
Clean up some of the code based on review and errors
Change the description to force the reader to implement more of
`EventCategory` on their own.
Add instructions for `AuthenticationController` updates to use
`UserService`
Update the mermaid chart for class diagram
Fix small mistakes in wording or missing variables/method names
Copy link
Contributor

@gildedgardenia gildedgardenia left a comment

Choose a reason for hiding this comment

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

Here are my suggestions for you! Thanks for your work on this, Ben!

Clean up language and grammar in the lessons.
Implement some fixes to code snippets.
Add numbered lists instead of unordered lists.
Remove unneeded sections based on code refactor
Add intro description to the Bonus Module
Leave hints about implementing the `Tag` class changes in the instructions
Update code to match latest version of project
This leaves the bonus module as a strictly text-based walkthrough
and roles & privileges to restrict access to the Coding Events based
on assigned user roles.

### TODO: Add Embedded Intro video
Copy link
Author

Choose a reason for hiding this comment

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

I think including the preview video that I made might be useful here, to show students what they will be building by the end of the walkthrough

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