Skip to content

Add student verification

Take the student ID and password from a sign-up form, check enrollment, and fetch only student ID, name and major. The password is neither stored nor logged.

A wrong password stops at the first failure. There is no retry, so the library never locks the account.

Names follow Python snake_case; Node.js and Java use camelCase. A portal login is required.

Method Parameter Type Required Default Meaning
authenticate student_id string Yes Student ID
password string Yes Portal password. Never stored or logged
include_raw boolean No false Also return the portal’s raw text (rawHtml, rawJson)
include_extra boolean No false Return the school’s remaining SIS fields as extra
authenticate_dhc student_id, password, include_raw When only student ID, name, major, year and status are needed (lighter, no contact lookup)

The result authenticate returns (top) and the value the example function hands back to the sign-up form (bottom). Field names are Python snake_case (student_id); Node.js and Java use camelCase (studentId, getStudentId()). Values are made-up and only show the shape.

{
"success": true,
"student_id": "20000000",
"name": "홍길동",
"major": "컴퓨터공학과",
"grade": "3",
"status": "재학",
"email": "user@example.com",
"phone_number": "010-0000-0000",
"english_name": "Gildong Hong",
"user_category": "학부생"
}
{ "verified": true, "student_id": "20000000", "name": "홍길동", "major": "컴퓨터공학과" }
Field Meaning
student_id / name / major Student ID / name / major. What the example function returns
status Enrollment status (enrolled, on leave, graduated, …). The portal’s own text, so the wording can change
grade Year of study (string)
email / phone_number / english_name / user_category Contact (SIS) lookup. null when the SIS lookup fails. The other SIS school-code fields are omitted here
verified Built by the example function by comparing status with the enrolled value. Not a library field

All fields: Result fields.

On failure: a wrong password, a locked account and so on are thrown as SejongAuthError (with an error code). Error codes

  • Never resend a wrong password repeatedly. The portal locks the account. The library stops at the first failure, but if anyone can type a student ID into your form, limit failures per student ID. Login verdict and account lock protection
  • status and major are the portal’s own strings. The 재학 comparison above is an example; keep it as a constant in one place since the wording can change.
  • One authenticate call includes the contact (SIS) lookup. If you only need student ID, name and major, the DHC-only call authenticate_dhc / authenticateDhc / authenticateWithDHC is lighter. See Authentication methods and Result fields.
  • Call it from a server only. Calling from a browser or app exposes the password to third-party code.
  • Branch on the error code, never on the message. Error codes

The user-facing messages are in Korean in the original examples; replace them with your own. ACTIVE_STATUS = "재학" is the portal’s own string for “enrolled” and must stay as the school sends it.

import kr.suhsaechan.sejongpeia.auth.model.SejongAuthResult;
import kr.suhsaechan.sejongpeia.auth.service.SuhSejongAuthEngine;
import kr.suhsaechan.sejongpeia.common.exception.SejongAuthErrorCode;
import kr.suhsaechan.sejongpeia.common.exception.SejongAuthException;
import org.springframework.stereotype.Service;
@Service
class StudentVerificationService {
private static final String ACTIVE_STATUS = "재학"; // compare with the school's own string
private final SuhSejongAuthEngine sejongAuthEngine;
StudentVerificationService(SuhSejongAuthEngine sejongAuthEngine) {
this.sejongAuthEngine = sejongAuthEngine;
}
/** Return only name and major; the password is not kept */
String verifySejongStudent(String studentId, String password) {
try {
SejongAuthResult result = sejongAuthEngine.authenticate(studentId, password);
boolean isActiveStudent = ACTIVE_STATUS.equals(result.getStatus());
return isActiveStudent ? result.getName() + " (" + result.getMajor() + ")" : "Not an enrolled student";
} catch (SejongAuthException exception) {
SejongAuthErrorCode errorCode = exception.getErrorCode();
if (errorCode == SejongAuthErrorCode.AUTHENTICATION_FAILED) {
return "Wrong student ID or password";
}
if (errorCode == SejongAuthErrorCode.ACCOUNT_LOCKED) {
return "The portal account is locked. Reset the password on the portal";
}
return "Cannot verify right now. Try again later";
}
}
}